Minor changes since I was a little bored ;)
[collectd.git] / src / common.c
index 4d93f4a..43a51a5 100644 (file)
@@ -46,35 +46,51 @@ static char *rra_def[] =
 static int rra_num = 9;
 #endif /* HAVE_LIBRRD */
 
-void
-sstrncpy(char *d, const char *s, int len)
+void sstrncpy (char *d, const char *s, int len)
 {
-       strncpy(d, s, len);
-       d[len - 1] = 0;
+       strncpy (d, s, len);
+       d[len - 1] = '\0';
 }
 
-char *
-sstrdup(const char *s)
+char *sstrdup (const char *s)
 {
-       char *r = strdup(s);
-       if(r == NULL) {
-               DBG("Not enough memory.");
+       char *r;
+
+       if((r = strdup (s)) == NULL)
+       {
+               DBG ("Not enough memory.");
                exit(3);
        }
-       return r;
+
+       return (r);
 }
 
-void *
-smalloc(size_t size)
+void *smalloc (size_t size)
 {
-       void *r = malloc(size);
-       if(r == NULL) {
+       void *r;
+
+       if ((r = malloc (size)) == NULL)
+       {
                DBG("Not enough memory.");
                exit(3);
        }
+
        return r;
 }
 
+#if 0
+void sfree (void **ptr)
+{
+       if (ptr == NULL)
+               return;
+
+       if (*ptr != NULL)
+               free (*ptr);
+
+       *ptr = NULL;
+}
+#endif
+
 int strsplit (char *string, char **fields, size_t size)
 {
        size_t i;