lib: Simplify load_case_tables_library()
authorVolker Lendecke <vl@samba.org>
Sun, 7 Dec 2014 11:08:55 +0000 (12:08 +0100)
committerJeremy Allison <jra@samba.org>
Sun, 7 Dec 2014 23:33:06 +0000 (00:33 +0100)
We don't really need a talloc context here

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
lib/util/charset/codepoints.c

index 0984164d4838dffd46a2a4d7d596b06eb0cf937c..499cea42f0969efd2bbad46de766941d1ce264c1 100644 (file)
@@ -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;