svn commit: samba r2901 - in branches/SAMBA_4_0/source/lib: .

tridge at samba.org tridge at samba.org
Mon Oct 11 02:07:31 GMT 2004


Author: tridge
Date: 2004-10-11 02:07:30 +0000 (Mon, 11 Oct 2004)
New Revision: 2901

WebSVN: http://websvn.samba.org/websvn/changeset.php?rep=samba&path=/branches/SAMBA_4_0/source/lib&rev=2901&nolog=1

Log:
if we can't load upcase.dat or lowcase.dat then don't waste 256k
making fake tables, instead just do the approximate upper/lower inline
with toupper() and tolower().

Modified:
   branches/SAMBA_4_0/source/lib/util_unistr.c


Changeset:
Modified: branches/SAMBA_4_0/source/lib/util_unistr.c
===================================================================
--- branches/SAMBA_4_0/source/lib/util_unistr.c	2004-10-11 01:03:27 UTC (rev 2900)
+++ branches/SAMBA_4_0/source/lib/util_unistr.c	2004-10-11 02:07:30 UTC (rev 2901)
@@ -32,7 +32,6 @@
 ********************************************************************/
 static void load_case_tables(void)
 {
-	int i;
 	TALLOC_CTX *mem_ctx;
 
 	mem_ctx = talloc_init("load_case_tables");
@@ -42,35 +41,11 @@
 	upcase_table = map_file(lib_path(mem_ctx, "upcase.dat"), 0x20000);
 	lowcase_table = map_file(lib_path(mem_ctx, "lowcase.dat"), 0x20000);
 	talloc_destroy(mem_ctx);
-	
-	/* we would like Samba to limp along even if these tables are
-	   not available */
 	if (upcase_table == NULL) {
-		DEBUG(1,("creating lame upcase table\n"));
-		upcase_table = talloc_named_const(NULL, 0x20000, "upcase_table");
-		if (!upcase_table) {
-			smb_panic("No memory for upcase tables");
-		}
-		for (i=0;i<0x10000;i++) {
-			SSVAL(upcase_table, i*2, i);
-		}
-		for (i=0;i<256;i++) {
-			SSVAL(upcase_table, i*2, islower(i)?toupper(i):i);
-		}
+		upcase_table = (void *)-1;
 	}
-
 	if (lowcase_table == NULL) {
-		DEBUG(1,("creating lame lowcase table\n"));
-		lowcase_table = talloc_named_const(NULL, 0x20000, "lowcase_table");
-		if (!lowcase_table) {
-			smb_panic("No memory for lowcase tables");
-		}
-		for (i=0;i<0x10000;i++) {
-			SSVAL(lowcase_table, i*2, i);
-		}
-		for (i=0;i<256;i++) {
-			SSVAL(lowcase_table, i*2, isupper(i)?tolower(i):i);
-		}
+		lowcase_table = (void *)-1;
 	}
 }
 
@@ -88,6 +63,9 @@
 	if (upcase_table == NULL) {
 		load_case_tables();
 	}
+	if (upcase_table == (void *)-1) {
+		return val;
+	}
 	return SVAL(upcase_table, val*2);
 }
 
@@ -105,6 +83,9 @@
 	if (lowcase_table == NULL) {
 		load_case_tables();
 	}
+	if (lowcase_table == (void *)-1) {
+		return val;
+	}
 	return SVAL(lowcase_table, val*2);
 }
 



More information about the samba-cvs mailing list