Răsfoiți Sursa

* Should be using calloc() here not my_calloc()

svn: 1910
Bryan Drewery 21 ani în urmă
părinte
comite
0e1536509e
1 a modificat fișierele cu 9 adăugiri și 9 ștergeri
  1. 9 9
      src/sorthelp.c

+ 9 - 9
src/sorthelp.c

@@ -57,10 +57,10 @@ char *step_thru_file(FILE *fd)
     fgets(tempBuf, sizeof(tempBuf), fd);
     if (!feof(fd)) {
       if (retStr == NULL) {
-        retStr = (char *) my_calloc(1, strlen(tempBuf) + 2);
+        retStr = (char *) calloc(1, strlen(tempBuf) + 2);
         strcpy(retStr, tempBuf);
       } else {
-        retStr = (char *) my_realloc(retStr, strlen(retStr) + strlen(tempBuf));
+        retStr = (char *) realloc(retStr, strlen(retStr) + strlen(tempBuf));
         strcat(retStr, tempBuf);
       }
       if (retStr[strlen(retStr)-1] == '\n') {
@@ -116,7 +116,7 @@ int my_cmp (const cmds *c1, const cmds *c2)
 
 int parse_help(char *infile, char *outfile) {
   FILE *in = NULL, *out = NULL;
-  char *buffer = NULL, my_buf[BUFSIZE] = "", *fulllist = (char *) my_calloc(1, 1);
+  char *buffer = NULL, my_buf[BUFSIZE] = "", *fulllist = (char *) calloc(1, 1);
   int skip = 0, line = 0, i = 0, leaf = 0, hub = 0;
 
   if (!(in = fopen(infile, "r"))) {
@@ -131,7 +131,7 @@ int parse_help(char *infile, char *outfile) {
       if (strchr(buffer, '\n')) *(char*)strchr(buffer, '\n') = 0;
       if ((skipline(buffer, &skip))) continue;
       if (buffer[0] == ':') { //New cmd 
-        char *ifdef = (char *) my_calloc(1, strlen(buffer) + 1), *p;
+        char *ifdef = (char *) calloc(1, strlen(buffer) + 1), *p;
 
         buffer++;
         strcpy(ifdef, buffer);
@@ -147,7 +147,7 @@ int parse_help(char *infile, char *outfile) {
         /* finish last command */
         if (my_buf && my_buf[0]) {
           my_buf[strlen(my_buf)] = 0;
-          cmdlist[cmdi].txt = (char *) my_calloc(1, strlen(my_buf) + 1);
+          cmdlist[cmdi].txt = (char *) calloc(1, strlen(my_buf) + 1);
           strcpy(cmdlist[cmdi].txt, my_buf);
           i++;
           cmdi++;
@@ -168,7 +168,7 @@ int parse_help(char *infile, char *outfile) {
               my_buf[0] = 0;
               continue;
             }
-          cmdlist[cmdi].name = (char *) my_calloc(1, strlen(p) + 1);
+          cmdlist[cmdi].name = (char *) calloc(1, strlen(p) + 1);
           strcpy(cmdlist[cmdi].name, p);
         } else {			/* END */
           break;
@@ -188,7 +188,7 @@ int parse_help(char *infile, char *outfile) {
   qsort(cmdlist, cmdi, sizeof(cmds), (int (*)(const void *, const void *)) &my_cmp);
 
   for (i = 0; i < cmdi; i++ ) {
-    fulllist = (char *) my_realloc(fulllist, strlen(fulllist) + strlen(cmdlist[i].name) + 2);
+    fulllist = (char *) realloc(fulllist, strlen(fulllist) + strlen(cmdlist[i].name) + 2);
     strcat(fulllist, cmdlist[i].name);
     strcat(fulllist, " ");
     fprintf(out, ":");
@@ -211,9 +211,9 @@ int main(int argc, char **argv) {
   int ret = 0;
 
   if (argc < 3) return 1;
-  in = (char *) my_calloc(1, strlen(argv[1]) + 1);
+  in = (char *) calloc(1, strlen(argv[1]) + 1);
   strcpy(in, argv[1]);
-  out = (char *) my_calloc(1, strlen(argv[2]) + 1);
+  out = (char *) calloc(1, strlen(argv[2]) + 1);
   strcpy(out, argv[2]);
   ret = parse_help(in, out);
   free(in);