mirror of
https://github.com/samba-team/samba.git
synced 2025-01-03 01:18:10 +03:00
lib: Avoid 70k of r/w memory
This adds more .text than it strips .data, but .text is shared between all processes, .data is copied. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
parent
24ad425e28
commit
6877e4849e
@ -94,34 +94,17 @@ def generateSourceFile(out_file, errors):
|
||||
out_file.write(" * see http://msdn.microsoft.com/en-us/library/cc704587.aspx\n")
|
||||
out_file.write(" */\n")
|
||||
out_file.write("\n")
|
||||
out_file.write("static const struct {\n")
|
||||
out_file.write(" HRESULT error_code;\n")
|
||||
out_file.write(" const char *error_str;\n")
|
||||
out_file.write(" const char *error_message;\n")
|
||||
out_file.write("} hresult_errs[] = {\n")
|
||||
|
||||
for err in errors:
|
||||
out_file.write(" {\n")
|
||||
if err.isWinError:
|
||||
out_file.write(" HRESULT_FROM_WIN32(%s),\n"%err.err_define)
|
||||
out_file.write(" \"HRESULT_FROM_WIN32(%s)\",\n"%err.err_define)
|
||||
else:
|
||||
out_file.write(" %s,\n"%err.err_define)
|
||||
out_file.write(" \"%s\",\n"%err.err_define)
|
||||
out_file.write(" \"%s\"\n"%err.err_string)
|
||||
out_file.write(" },\n")
|
||||
out_file.write("};\n")
|
||||
out_file.write("\n")
|
||||
out_file.write("const char *hresult_errstr_const(HRESULT err_code)\n")
|
||||
out_file.write("{\n")
|
||||
out_file.write(" const char *result = NULL;\n")
|
||||
out_file.write(" size_t i;\n")
|
||||
out_file.write(" for (i = 0; i < ARRAY_SIZE(hresult_errs); ++i) {\n")
|
||||
out_file.write(" if (HRES_IS_EQUAL(err_code, hresult_errs[i].error_code)) {\n")
|
||||
out_file.write(" result = hresult_errs[i].error_message;\n")
|
||||
out_file.write(" break;\n")
|
||||
out_file.write(" }\n")
|
||||
out_file.write("\n")
|
||||
out_file.write(" switch (HRES_ERROR_V(err_code)) {\n")
|
||||
for err in errors:
|
||||
out_file.write(f' case 0x{err.err_code:X}:\n')
|
||||
out_file.write(f' result = \"{err.err_define}\";\n')
|
||||
out_file.write(f' break;\n')
|
||||
out_file.write(" }\n")
|
||||
out_file.write("\n")
|
||||
out_file.write(" /* convert & check win32 error space? */\n")
|
||||
out_file.write(" if (result == NULL && HRESULT_IS_LIKELY_WERR(err_code)) {\n")
|
||||
out_file.write(" WERROR wErr = W_ERROR(WIN32_FROM_HRESULT(err_code));\n")
|
||||
@ -133,12 +116,12 @@ def generateSourceFile(out_file, errors):
|
||||
out_file.write("const char *hresult_errstr(HRESULT err_code)\n")
|
||||
out_file.write("{\n")
|
||||
out_file.write(" static char msg[22];\n")
|
||||
out_file.write(" size_t i;\n")
|
||||
out_file.write("\n")
|
||||
out_file.write(" for (i = 0; i < ARRAY_SIZE(hresult_errs); i++) {\n")
|
||||
out_file.write(" if (HRES_IS_EQUAL(err_code, hresult_errs[i].error_code)) {\n")
|
||||
out_file.write(" return hresult_errs[i].error_str;\n")
|
||||
out_file.write(" }\n")
|
||||
out_file.write(" switch (HRES_ERROR_V(err_code)) {\n")
|
||||
for err in errors:
|
||||
out_file.write(f' case 0x{err.err_code:X}:\n')
|
||||
out_file.write(f' return \"{err.err_string}\";\n')
|
||||
out_file.write(f' break;\n')
|
||||
out_file.write(" }\n")
|
||||
out_file.write(" snprintf(msg, sizeof(msg), \"HRES code 0x%08x\", HRES_ERROR_V(err_code));\n")
|
||||
out_file.write(" return msg;\n")
|
||||
|
Loading…
Reference in New Issue
Block a user