[SCM] Samba Shared Repository - branch v3-2-test updated - initial-v3-2-unstable-1201-g2150663

Volker Lendecke vl at samba.org
Tue Jan 8 23:07:52 GMT 2008


The branch, v3-2-test has been updated
       via  2150663d9eaf5cdab08de2ad1fcc952d7e85936c (commit)
       via  28a72ebd4541fb54f284da49081345e54130c75a (commit)
      from  ef7c9a765bcdb1c774ff4f6d14053c4aa3815f31 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-2-test


- Log -----------------------------------------------------------------
commit 2150663d9eaf5cdab08de2ad1fcc952d7e85936c
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Jan 8 23:18:03 2008 +0100

    Save one popular malloc

commit 28a72ebd4541fb54f284da49081345e54130c75a
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Jan 8 22:42:27 2008 +0100

    Don't shrink a talloc area if we have less than 1k to gain

-----------------------------------------------------------------------

Summary of changes:
 source/lib/ms_fnmatch.c    |   24 ++++++++++++++++++------
 source/lib/talloc/talloc.c |    5 +++++
 2 files changed, 23 insertions(+), 6 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/lib/ms_fnmatch.c b/source/lib/ms_fnmatch.c
index a839b42..8b69f1c 100644
--- a/source/lib/ms_fnmatch.c
+++ b/source/lib/ms_fnmatch.c
@@ -152,6 +152,8 @@ int ms_fnmatch(const char *pattern, const char *string, bool translate_pattern,
 	smb_ucs2_t *s = NULL;
 	int ret, count, i;
 	struct max_n *max_n = NULL;
+	struct max_n *max_n_free = NULL;
+	struct max_n one_max_n;
 
 	if (ISDOTDOT(string)) {
 		string = ".";
@@ -201,17 +203,27 @@ int ms_fnmatch(const char *pattern, const char *string, bool translate_pattern,
 	}
 
 	if (count != 0) {
-		max_n = SMB_CALLOC_ARRAY(struct max_n, count);
-		if (!max_n) {
-			SAFE_FREE(p);
-			SAFE_FREE(s);
-			return -1;
+		if (count == 1) {
+			/*
+			 * We're doing this a LOT, so save the effort to allocate
+			 */
+			ZERO_STRUCT(one_max_n);
+			max_n = &one_max_n;
+		}
+		else {
+			max_n = SMB_CALLOC_ARRAY(struct max_n, count);
+			if (!max_n) {
+				SAFE_FREE(p);
+				SAFE_FREE(s);
+				return -1;
+			}
+			max_n_free = max_n;
 		}
 	}
 
 	ret = ms_fnmatch_core(p, s, max_n, strrchr_w(s, UCS2_CHAR('.')), is_case_sensitive);
 
-	SAFE_FREE(max_n);
+	SAFE_FREE(max_n_free);
 	SAFE_FREE(p);
 	SAFE_FREE(s);
 	return ret;
diff --git a/source/lib/talloc/talloc.c b/source/lib/talloc/talloc.c
index 4d72c0e..6dbe21b 100644
--- a/source/lib/talloc/talloc.c
+++ b/source/lib/talloc/talloc.c
@@ -787,6 +787,11 @@ void *_talloc_realloc(const void *context, void *ptr, size_t size, const char *n
 
 	tc = talloc_chunk_from_ptr(ptr);
 
+	if ((size < tc->size) && ((tc->size - size) < 1024)) {
+		tc->size = size;
+		return ptr;
+	}
+
 	/* don't allow realloc on referenced pointers */
 	if (unlikely(tc->refs)) {
 		return NULL;


-- 
Samba Shared Repository


More information about the samba-cvs mailing list