On Sat, Nov 15, 2014 at 06:42:34PM +0100, Nicolas Bedos wrote:
> dbv = malloc(sizeof(char **))
>
> which I believe should be
>
> dbv = malloc(sizeof(char *))
Correct. While at it, we should also fix the examples in the comment.
Tobias
Index: util.c
===================================================================
RCS file: /cvs/src/usr.bin/locate/locate/util.c,v
retrieving revision 1.11
diff -u -p -r1.11 util.c
--- util.c 8 Oct 2014 04:04:37 -0000 1.11
+++ util.c 15 Nov 2014 18:10:33 -0000
@@ -72,8 +72,8 @@ check_bigram_char(ch)
/* split a colon separated string into a char vector
*
- * "bla:foo" -> {"foo", "bla"}
- * "bla:" -> {"foo", dot}
+ * "bla:foo" -> {"bla", "foo"}
+ * "bla:" -> {"bla", dot}
* "bla" -> {"bla"}
* "" -> do nothing
*
@@ -89,7 +89,7 @@ colon(dbv, path, dot)
char **pv;
if (dbv == NULL) {
- if ((dbv = malloc(sizeof(char **))) == NULL)
+ if ((dbv = malloc(sizeof(char *))) == NULL)
err(1, "malloc");
*dbv = NULL;
}
@@ -123,7 +123,7 @@ colon(dbv, path, dot)
}
/* increase dbv with element p */
if ((newdbv = reallocarray(dbv, vlen + 2,
- sizeof(char **))) == NULL)
+ sizeof(char *))) == NULL)
err(1, "realloc");
dbv = newdbv;
*(dbv + vlen) = p;