[xiph-commits] r11552 - icecast/trunk/ices0/src/playlist

brendan at svn.xiph.org brendan at svn.xiph.org
Fri Jun 9 15:55:51 PDT 2006


Author: brendan
Date: 2006-06-09 15:55:50 -0700 (Fri, 09 Jun 2006)
New Revision: 11552

Modified:
   icecast/trunk/ices0/src/playlist/rand.c
Log:
Reindent before edit.


Modified: icecast/trunk/ices0/src/playlist/rand.c
===================================================================
--- icecast/trunk/ices0/src/playlist/rand.c	2006-06-09 14:25:50 UTC (rev 11551)
+++ icecast/trunk/ices0/src/playlist/rand.c	2006-06-09 22:55:50 UTC (rev 11552)
@@ -42,8 +42,8 @@
 /*** struct for the linked lists ***/
 struct ll
 {
-	char *data;
-	struct ll *next;
+  char *data;
+  struct ll *next;
 };
 
 /* Private function declarations */
@@ -64,70 +64,65 @@
 static void 
 scramble (FILE *fp, FILE *out)
 {
-	char *line_storage = NULL, **table = NULL;
-	struct ll *llist = NULL, *ptr = NULL;
-	int size = 0, n = 0, x = 0;
-	
-	srand (ices_util_get_random ());
-	
-	llist = malloc (sizeof (struct ll));
-	llist->data = NULL;
-	ptr = llist;
-	
-	line_storage = (char *) malloc (sizeof (char) * 1024 + 2);
-	
-	/*** make linked list     ***/
-	if (method == LINE) {
-		while (fgets (line_storage, 1024, fp)) {
-			struct ll *x = malloc (sizeof (struct ll));
-			x->data = malloc (strlen (line_storage) * sizeof (char) + 2);
-			memcpy (x->data, line_storage, strlen (line_storage) * sizeof (char) + 1);
-			x->data[strlen (x->data) - 1] = 0;
-			x->next = NULL;
-			ptr->next = x;
-			ptr = x;
-			size++;
-		}
-	}
-	
-	/*** make table from list ***/
-	table = malloc (size * sizeof (void *));
-	ptr = llist->next;
-	for (x = 0; x < size; x++) {
-		table[x] = ptr->data;
-		ptr = ptr->next;
-	}
-	
-	
-	/* shuffle it  (thanks to Dr Shade) */
-	n = size;
-	
-	while (n > 1) {
-		int d = (int)((double)size * rand() / (RAND_MAX + 1.0));
-		char *temp = table[d];
-		table[d] = table[n-1];
-		table[n-1] = temp;
-		--n;
-	}
-	
-	/*** print it   ***/
-	while (size) {
-		fprintf (out, "%s\n", table[size - 1]);
-		size--;
-	}
-	
-	/*** delete the linked list and clean up ***/
-	
-	ptr = llist->next;
-	while (ptr) {
-		free (llist);
-		llist = ptr;
-		ptr =ptr->next;
-	}
-	
-	free (line_storage);
-	return;
-}
+  char *line_storage = NULL, **table = NULL;
+  struct ll *llist = NULL, *ptr = NULL;
+  int size = 0, n = 0, x = 0;
 
+  srand (ices_util_get_random ());
 
+  llist = malloc (sizeof (struct ll));
+  llist->data = NULL;
+  ptr = llist;
 
+  line_storage = (char *) malloc (sizeof (char) * 1024 + 2);
+
+  /*** make linked list     ***/
+  if (method == LINE) {
+    while (fgets (line_storage, 1024, fp)) {
+      struct ll *x = malloc (sizeof (struct ll));
+      x->data = malloc (strlen (line_storage) * sizeof (char) + 2);
+      memcpy (x->data, line_storage, strlen (line_storage) * sizeof (char) + 1);
+      x->data[strlen (x->data) - 1] = 0;
+      x->next = NULL;
+      ptr->next = x;
+      ptr = x;
+      size++;
+    }
+  }
+
+  /*** make table from list ***/
+  table = malloc (size * sizeof (void *));
+  ptr = llist->next;
+  for (x = 0; x < size; x++) {
+    table[x] = ptr->data;
+    ptr = ptr->next;
+  }
+
+  /* shuffle it  (thanks to Dr Shade) */
+  n = size;
+
+  while (n > 1) {
+    int d = (int)((double)size * rand() / (RAND_MAX + 1.0));
+    char *temp = table[d];
+    table[d] = table[n-1];
+    table[n-1] = temp;
+    --n;
+  }
+
+  /*** print it   ***/
+  while (size) {
+    fprintf (out, "%s\n", table[size - 1]);
+    size--;
+  }
+
+  /*** delete the linked list and clean up ***/
+  ptr = llist->next;
+  while (ptr) {
+    free (llist);
+    llist = ptr;
+    ptr =ptr->next;
+  }
+
+  free (line_storage);
+  return;
+}



More information about the commits mailing list