comparison lib-src/sorted-doc.c @ 440:8de8e3f6228a r21-2-28

Import from CVS: tag r21-2-28
author cvs
date Mon, 13 Aug 2007 11:33:38 +0200
parents 84b14dcb0985
children abe6d1db359e
comparison
equal deleted inserted replaced
439:357dd071b03c 440:8de8e3f6228a
9 9
10 #include <config.h> 10 #include <config.h>
11 11
12 #include <stdio.h> 12 #include <stdio.h>
13 #include <ctype.h> 13 #include <ctype.h>
14 #if __STDC__ || defined(STDC_HEADERS) 14 #include <stdlib.h> /* for qsort() and malloc() */
15 # include <stdlib.h> /* for qsort() and malloc() */ 15 #include <string.h>
16 # include <string.h> 16 static void *xmalloc (size_t);
17 static void *xmalloc (int); 17 #ifndef CONST
18 # ifndef CONST 18 # define CONST const
19 # define CONST const
20 # endif
21 #else
22 extern char *malloc ();
23 static void *xmalloc ();
24 # ifndef CONST
25 # define CONST
26 # endif
27 #endif 19 #endif
28 20
29 #define NUL '\0' 21 #define NUL '\0'
30 #define MARKER '\037' 22 #define MARKER '\037'
31 23
32 #define DEBUG 0 24 #define DEBUG 0
33 25
34 typedef struct line LINE; 26 typedef struct LINE LINE;
35 27
36 struct line 28 struct LINE
37 { 29 {
38 LINE *next; /* ptr to next or NULL */ 30 LINE *next; /* ptr to next or NULL */
39 char *line; /* text of the line */ 31 char *line; /* text of the line */
40 }; 32 };
41 33
70 } 62 }
71 63
72 /* Like malloc but get fatal error if memory is exhausted. */ 64 /* Like malloc but get fatal error if memory is exhausted. */
73 65
74 static void * 66 static void *
75 xmalloc (int size) 67 xmalloc (size_t size)
76 { 68 {
77 char *result = malloc ((unsigned)size); 69 void *result = malloc (size);
78 if (result == NULL) 70 if (result == NULL)
79 fatal ("%s", "virtual memory exhausted"); 71 fatal ("%s", "virtual memory exhausted");
80 return result; 72 return result;
81 } 73 }
82 74
83 static char * 75 static char *
84 strsav (char *str) 76 strsav (char *str)
85 { 77 {
86 char *buf = xmalloc (strlen (str) + 1); 78 char *buf = (char *) xmalloc (strlen (str) + 1);
87 (void) strcpy (buf, str); 79 strcpy (buf, str);
88 return (buf); 80 return buf;
89 } 81 }
90 82
91 /* Comparison function for qsort to call. */ 83 /* Comparison function for qsort to call. */
92 84
93 static int 85 static int