From 95695c1b540f7006ec679af92b10771d8e1d8195 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 23 Sep 2017 21:12:50 +0200 Subject: [PATCH] remove log_orders because I'm never using it and it costs time. reduce memory reserved for balloc. --- src/reports.c | 19 ------------------- src/util/translation.c | 10 ++++------ 2 files changed, 4 insertions(+), 25 deletions(-) diff --git a/src/reports.c b/src/reports.c index 8e91bd3da..1182f89c9 100644 --- a/src/reports.c +++ b/src/reports.c @@ -2147,23 +2147,6 @@ static void eval_int36(struct opstack **stack, const void *userdata) /*** END MESSAGE RENDERING ***/ -#include - -static void log_orders(const struct message *msg) -{ - char buffer[4096]; - int i; - - for (i = 0; i != msg->type->nparameters; ++i) { - if (msg->type->types[i]->copy == &var_copy_order) { - const char *section = nr_section(msg); - nr_render(msg, default_locale, buffer, sizeof(buffer), NULL); - log_debug("MESSAGE [%s]: %s\n", section, buffer); - break; - } - } -} - int stream_printf(struct stream * out, const char *format, ...) { va_list args; @@ -2226,8 +2209,6 @@ void register_reports(void) register_argtype("items", var_free_resources, var_copy_items, VAR_VOIDPTR); register_argtype("regions", var_free_regions, NULL, VAR_VOIDPTR); - msg_log_create = &log_orders; - /* register functions that turn message contents to readable strings */ add_function("alliance", &eval_alliance); add_function("region", &eval_region); diff --git a/src/util/translation.c b/src/util/translation.c index fb89a5af9..290e28c16 100644 --- a/src/util/translation.c +++ b/src/util/translation.c @@ -71,7 +71,7 @@ void opstack_push(opstack ** stackp, variant data) ** static buffer malloc **/ -#define BBUFSIZE 0x20000 +#define BBUFSIZE 0x10000 static struct { char *begin; char *end; @@ -81,16 +81,13 @@ static struct { char *balloc(size_t size) { - static int init = 0; /* STATIC_XCALL: used across calls */ + static int init = 0; if (!init) { init = 1; buffer.current = buffer.begin = malloc(BBUFSIZE * sizeof(char)); buffer.end = buffer.begin + BBUFSIZE; } - if (buffer.current + size > buffer.end) { - /* out of memory! */ - return NULL; - } + assert(buffer.current + size <= buffer.end || !"balloc is out of memory"); buffer.last = buffer.current; buffer.current += size; return buffer.last; @@ -99,6 +96,7 @@ char *balloc(size_t size) void bfree(char *c) /* only release this memory if it was part of the last allocation * that's a joke, but who cares. + * I'm afraid I don't get the joke. */ { if (c >= buffer.last && c < buffer.current)