summaryrefslogtreecommitdiff
path: root/ftpfs
diff options
context:
space:
mode:
authorMarcus Brinkmann <marcus@gnu.org>2001-01-07 17:04:49 +0000
committerMarcus Brinkmann <marcus@gnu.org>2001-01-07 17:04:49 +0000
commit08acb4201d53562fcbcece79de54b7314a7f8f9d (patch)
tree83504717bc9cabfb687ccf46e3a1cef2fd35c078 /ftpfs
parent58ef6ed22655adf4a797bedb85da862f872b10b8 (diff)
2000-12-21 Marcus Brinkmann <marcus@gnu.org>
* dir.c (ftpfs_dir_create): New macro INIT_HTABLE_LEN to specify initialize htable_len. New variable htable, allocate memory to it with calloc before acquiring a node reference. If this fails, return any allocated memory and return with ENOMEM. Set new->htable_len to INIT_HTABLE_LEN and new->htable to htable. Don't bzero htable anymore, as we use calloc.
Diffstat (limited to 'ftpfs')
-rw-r--r--ftpfs/ChangeLog10
-rw-r--r--ftpfs/dir.c20
2 files changed, 25 insertions, 5 deletions
diff --git a/ftpfs/ChangeLog b/ftpfs/ChangeLog
index 9c69c5a9..a339fec7 100644
--- a/ftpfs/ChangeLog
+++ b/ftpfs/ChangeLog
@@ -1,3 +1,13 @@
+2000-12-21 Marcus Brinkmann <marcus@gnu.org>
+
+ * dir.c (ftpfs_dir_create): New macro INIT_HTABLE_LEN to
+ specify initialize htable_len. New variable htable,
+ allocate memory to it with calloc before acquiring a node
+ reference. If this fails, return any allocated memory and
+ return with ENOMEM. Set new->htable_len to INIT_HTABLE_LEN
+ and new->htable to htable. Don't bzero htable anymore, as
+ we use calloc.
+
2000-07-26 Mark Kettenis <kettenis@gnu.org>
* Makefile (HURDLIBS): Reorder libs such that the threads lib
diff --git a/ftpfs/dir.c b/ftpfs/dir.c
index f083848a..462567f6 100644
--- a/ftpfs/dir.c
+++ b/ftpfs/dir.c
@@ -806,6 +806,9 @@ ftpfs_dir_null_lookup (struct ftpfs_dir *dir, struct node **node)
return err;
}
+/* Size of initial htable for a new directory. */
+#define INIT_HTABLE_LEN 5
+
/* Return in DIR a new ftpfs directory, in the filesystem FS, with node NODE
and remote path RMT_PATH. RMT_PATH is *not copied*, so it shouldn't ever
change while this directory is active. */
@@ -814,9 +817,17 @@ ftpfs_dir_create (struct ftpfs *fs, struct node *node, const char *rmt_path,
struct ftpfs_dir **dir)
{
struct ftpfs_dir *new = malloc (sizeof (struct ftpfs_dir));
+ struct ftpfs_dir_entry **htable
+ = calloc (INIT_HTABLE_LEN * sizeof (struct ftpfs_dir_entry *));
- if (! new)
- return ENOMEM;
+ if (!new || !htable)
+ {
+ if (new)
+ free (new);
+ if (htable)
+ free (htable);
+ return ENOMEM;
+ }
/* Hold a reference to the new dir's node. */
spin_lock (&netfs_node_refcnt_lock);
@@ -825,9 +836,8 @@ ftpfs_dir_create (struct ftpfs *fs, struct node *node, const char *rmt_path,
new->num_entries = 0;
new->num_live_entries = 0;
- new->htable_len = 5;
- new->htable = malloc (new->htable_len * sizeof (struct ftpfs_dir_entry *));
- bzero (new->htable, sizeof *new->htable * new->htable_len);
+ new->htable_len = INIT_HTABLE_LEN;
+ new->htable = htable;
new->ordered = 0;
new->rmt_path = rmt_path;
new->fs = fs;