From 35c256226f7cbf1125ad7b6370eecdf09b3cfbc6 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 8 Jan 2008 21:45:21 +0100 Subject: Allocate dirp->name_cache on demand only (This used to be commit 1a15778331393f9ece9aac9450828e799b20a058) --- source3/smbd/dir.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'source3') diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c index ab6e12f20f..04e3167e77 100644 --- a/source3/smbd/dir.c +++ b/source3/smbd/dir.c @@ -1139,16 +1139,6 @@ struct smb_Dir *OpenDir(connection_struct *conn, const char *name, const char *m goto fail; } - if (dirp->name_cache_size) { - dirp->name_cache = SMB_CALLOC_ARRAY(struct name_cache_entry, - dirp->name_cache_size); - if (!dirp->name_cache) { - goto fail; - } - } else { - dirp->name_cache = NULL; - } - dirhandles_open++; return dirp; @@ -1295,10 +1285,19 @@ void DirCacheAdd(struct smb_Dir *dirp, const char *name, long offset) { struct name_cache_entry *e; - if (!dirp->name_cache_size || !dirp->name_cache) { + if (dirp->name_cache_size == 0) { return; } + if (dirp->name_cache == NULL) { + dirp->name_cache = SMB_CALLOC_ARRAY(struct name_cache_entry, + dirp->name_cache_size); + + if (dirp->name_cache == NULL) { + return; + } + } + dirp->name_cache_index = (dirp->name_cache_index+1) % dirp->name_cache_size; e = &dirp->name_cache[dirp->name_cache_index]; -- cgit