diff options
author | Volker Lendecke <vl@samba.org> | 2008-01-08 21:45:21 +0100 |
---|---|---|
committer | Volker Lendecke <vl@samba.org> | 2008-01-08 22:18:08 +0100 |
commit | 35c256226f7cbf1125ad7b6370eecdf09b3cfbc6 (patch) | |
tree | 98e85f32ce4c802d6319c184fa53c2f7a9f654ae /source3 | |
parent | 7ca33d1112f415a41ed48be02a7f732a2c640ff7 (diff) | |
download | samba-35c256226f7cbf1125ad7b6370eecdf09b3cfbc6.tar.gz samba-35c256226f7cbf1125ad7b6370eecdf09b3cfbc6.tar.bz2 samba-35c256226f7cbf1125ad7b6370eecdf09b3cfbc6.zip |
Allocate dirp->name_cache on demand only
(This used to be commit 1a15778331393f9ece9aac9450828e799b20a058)
Diffstat (limited to 'source3')
-rw-r--r-- | source3/smbd/dir.c | 21 |
1 files changed, 10 insertions, 11 deletions
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]; |