]> andersk Git - moira.git/blobdiff - update/config.c
Correct offsets for both versions of gsnt.
[moira.git] / update / config.c
index 0f7b35c18474c19d526a07f3237ac2abb3bd3728..b40670a092381ecc6a410aa38be178dc2e19e69f 100644 (file)
@@ -17,6 +17,7 @@
 #include <sys/stat.h>
 
 #include <ctype.h>
+#include <errno.h>
 #include <fcntl.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -40,12 +41,11 @@ RCSID("$Header$");
 static char *config_buf = NULL;
 static char **config_keys, **config_values;
 
-
 static int init(void)
 {
   int fd, count = 0;
   struct stat st;
-  char *p;
+  char *p, *start;
 
   /* Only execute once */
   if (config_buf)
@@ -56,14 +56,19 @@ static int init(void)
     {
       config_buf = "";
       config_keys = malloc(sizeof(char *) * 2);
+      if (!config_keys)
+       return ENOMEM;
       config_keys[0] = config_keys[1] = NULL;
       return MR_SUCCESS;
     }
+
   if (fstat(fd, &st) < 0)
     return MR_INTERNAL;
+
   config_buf = malloc(st.st_size + 2);
   if (!config_buf)
-    return MR_NO_MEM;
+    return ENOMEM;
+
   if (read(fd, config_buf, st.st_size) < st.st_size)
     {
       free(config_buf);
@@ -83,13 +88,17 @@ static int init(void)
   if (!config_keys || !config_values)
     {
       free(config_buf);
+      free(config_keys);
+      free(config_values);
       config_buf = NULL;
-      return MR_NO_MEM;
+      return ENOMEM;
     }
+
   count = 0;
   for (p = strtok(config_buf, "\n"); p; p = strtok(NULL, "\n"))
     config_keys[count++] = p;
   config_keys[count] = NULL;
+
   for (count = 0; config_keys[count]; count++)
     {
       config_values[count] = "";
This page took 0.038045 seconds and 4 git commands to generate.