summaryrefslogtreecommitdiffstats
path: root/libidu/walker.c
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2008-01-04 16:29:18 +0100
committerJim Meyering <meyering@redhat.com>2008-01-30 21:34:33 +0100
commit79f0ffc240ee3fe6789a90ec01ae0503aced7927 (patch)
treefd6d5a9c9f487c6f869c2abddf4be05c9c51da72 /libidu/walker.c
parent3cda817f6cd73abfed5bdcc567735ad633904d41 (diff)
downloadidutils-79f0ffc240ee3fe6789a90ec01ae0503aced7927.tar.gz
idutils-79f0ffc240ee3fe6789a90ec01ae0503aced7927.tar.bz2
idutils-79f0ffc240ee3fe6789a90ec01ae0503aced7927.zip
Allocate safely.
* libidu/dynvec.c (make_dynvec, dynvec_freeze, dynvec_append): Use xnmalloc, not xmalloc (n * sizeof T). Use xnrealloc, not xrealloc (p, n * sizeof T). * libidu/walker.c (append_strings_to_vector, vectorize_string): Likewise. * libidu/scanners.c (tokenize_args_string): Likewise.
Diffstat (limited to 'libidu/walker.c')
-rw-r--r--libidu/walker.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/libidu/walker.c b/libidu/walker.c
index 30f826e..921421c 100644
--- a/libidu/walker.c
+++ b/libidu/walker.c
@@ -510,16 +510,17 @@ append_strings_to_vector (char **vector_0, char *string, char const *delimiter_c
if (vector_0)
{
int length = vector_length (vector_0);
- vector_0 = xrealloc (vector_0, sizeof(char *) * (length + 2 + strlen (string) / 2));
+ vector_0 = xnrealloc (vector_0, length + 2 + strlen (string) / 2,
+ sizeof *vector_0);
vector = &vector_0[length];
}
else
- vector = vector_0 = xmalloc (sizeof(char *) * (2 + strlen (string) / 2));
+ vector = vector_0 = xnmalloc (2 + strlen (string) / 2, sizeof *vector);
do
*vector = strsep (&string, delimiter_class);
while (*vector++);
- return xrealloc (vector_0, sizeof(char *) * (vector - vector_0));
+ return xnrealloc (vector_0, vector - vector_0, sizeof *vector_0);
}
int
@@ -701,7 +702,7 @@ vectorize_string (char *string, char const *delimiter_class)
*vector = strsep (&string, delimiter_class);
while (*vector++);
}
- return xrealloc (vector_0, sizeof(char *) * (vector - vector_0));
+ return xnrealloc (vector_0, vector - vector_0, sizeof *vector_0);
}
void