[PATCH] lib: Simplify load_case_tables_library()
Volker Lendecke
Volker.Lendecke at SerNet.DE
Sun Dec 7 05:35:21 MST 2014
Hi!
Review&push appreciated!
Thanks,
Volker
--
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de
-------------- next part --------------
From 043c1858058a34d856006d1c9cfe81832f8268c9 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Sun, 7 Dec 2014 12:08:55 +0100
Subject: [PATCH] lib: Simplify load_case_tables_library()
We don't really need a talloc context here
Signed-off-by: Volker Lendecke <vl at samba.org>
---
lib/util/charset/codepoints.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/lib/util/charset/codepoints.c b/lib/util/charset/codepoints.c
index 0984164..499cea4 100644
--- a/lib/util/charset/codepoints.c
+++ b/lib/util/charset/codepoints.c
@@ -47,15 +47,16 @@ This is the function that should be called from library code.
********************************************************************/
void load_case_tables_library(void)
{
- TALLOC_CTX *mem_ctx;
+ const char *codepagedir = get_dyn_CODEPAGEDIR();
+ size_t codepagedir_len = strlen(codepagedir);
+ char buf[codepagedir_len+13];
+
+ snprintf(buf, sizeof(buf), "%s/upcase.dat", codepagedir);
+ upcase_table = map_file(buf, 0x20000);
+
+ snprintf(buf, sizeof(buf), "%s/lowcase.dat", codepagedir);
+ lowcase_table = map_file(buf, 0x20000);
- mem_ctx = talloc_init("load_case_tables");
- if (!mem_ctx) {
- smb_panic("No memory for case_tables");
- }
- upcase_table = map_file(talloc_asprintf(mem_ctx, "%s/upcase.dat", get_dyn_CODEPAGEDIR()), 0x20000);
- lowcase_table = map_file(talloc_asprintf(mem_ctx, "%s/lowcase.dat", get_dyn_CODEPAGEDIR()), 0x20000);
- talloc_free(mem_ctx);
if (upcase_table == NULL) {
DEBUG(1, ("Failed to load upcase.dat, will use lame ASCII-only case sensitivity rules\n"));
upcase_table = (void *)-1;
--
1.9.1
More information about the samba-technical
mailing list