summaryrefslogtreecommitdiff
path: root/dircat.h
diff options
context:
space:
mode:
authorJeremie Koenig <jk@jk.fr.eu.org>2010-08-23 11:54:10 +0000
committerJeremie Koenig <jk@jk.fr.eu.org>2010-08-30 14:31:31 +0200
commit4646c4a3ef6171a0ddec4fcfe0c6aa34b50501cd (patch)
tree6b84772adf6f4c45c852dfc051b94995864caa86 /dircat.h
parent6e202c432e2f16dfa83a7dc21b759c03623fa394 (diff)
Improve the interface for dircat_make_node
* dircat.c, dircat.h (dircat_make_node): Use an explicit array size for DIRS, fail with ENOMEM is any of them is NULL, and release the reference on the non-NULL nodes on any error. * main.c (root_make_node): Use the new interface.
Diffstat (limited to 'dircat.h')
-rw-r--r--dircat.h17
1 files changed, 9 insertions, 8 deletions
diff --git a/dircat.h b/dircat.h
index cb22852..951d202 100644
--- a/dircat.h
+++ b/dircat.h
@@ -1,9 +1,10 @@
-/* Append the contents of multiple directories. DIRS is a
- NULL-terminated array of directory nodes. One reference is consumed
- for each of them, even on ENOMEM, in which case NULL is returned.
- DIRS has to be static data for now, or at list remain available and
- unchanged for the duration of the created node's life. Strange
- things will happen if they have entries with the same name or if one
- of them is not a directory. */
+/* Append the contents of NUM_DIRS directories. DIRS is an array of
+ directory nodes. One reference is consumed for each of them. If a
+ memory allocation error occurs, or if one of the directories is a
+ NULL pointer, the references are dropped immediately and NULL is
+ returned. The given DIRS array is duplicated and can therefore be
+ allocated on the caller's stack. Strange things will happen if some
+ elements of DIRS have entries with the same name or if one of them is
+ not a directory. */
struct node *
-dircat_make_node (struct node **dirs);
+dircat_make_node (struct node *const *dirs, int num_dirs);