diff options
author | Paul Smith <psmith@gnu.org> | 2009-09-16 17:07:01 +0000 |
---|---|---|
committer | Paul Smith <psmith@gnu.org> | 2009-09-16 17:07:01 +0000 |
commit | 8f30b68871bde8687c7fcff8bac66e2b5765129e (patch) | |
tree | 78e7e64f0c47dff023bebe15ee57b85f8db6a826 /ar.c | |
parent | 5abe47762071f024409f7fd16c9cb76b31833379 (diff) | |
download | gunmake-8f30b68871bde8687c7fcff8bac66e2b5765129e.tar.gz |
- Add xcalloc() and call it
- Fix memory errors found by valgrind
- Remove multi_glob() and empower parse_file_seq() to do its job:
the goal here is to remove the confusing reverse/re-reverse we do on
the file lists: needed for future fixes.
- Add a prefix arg to parse_file_seq()
- Make concat() variadic so it can take arbitrary #'s of strings
Diffstat (limited to 'ar.c')
-rw-r--r-- | ar.c | 13 |
1 files changed, 3 insertions, 10 deletions
@@ -196,9 +196,8 @@ ar_glob_match (int desc UNUSED, const char *mem, int truncated UNUSED, if (fnmatch (state->pattern, mem, FNM_PATHNAME|FNM_PERIOD) == 0) { /* We have a match. Add it to the chain. */ - struct nameseq *new = xmalloc (state->size); - memset (new, '\0', state->size); - new->name = strcache_add (concat (state->arname, mem, ")")); + struct nameseq *new = xcalloc (state->size); + new->name = strcache_add (concat (4, state->arname, "(", mem, ")")); new->next = state->chain; state->chain = new; ++state->n; @@ -249,7 +248,6 @@ ar_glob (const char *arname, const char *member_pattern, unsigned int size) struct ar_glob_state state; struct nameseq *n; const char **names; - char *name; unsigned int i; if (! glob_pattern_p (member_pattern, 1)) @@ -257,12 +255,7 @@ ar_glob (const char *arname, const char *member_pattern, unsigned int size) /* Scan the archive for matches. ar_glob_match will accumulate them in STATE.chain. */ - i = strlen (arname); - name = alloca (i + 2); - memcpy (name, arname, i); - name[i] = '('; - name[i + 1] = '\0'; - state.arname = name; + state.arname = arname; state.pattern = member_pattern; state.size = size; state.chain = 0; |