remove log_orders because I'm never using it and it costs time.

reduce memory reserved for balloc.
This commit is contained in:
Enno Rehling 2017-09-23 21:12:50 +02:00
parent 59169f3eb1
commit 95695c1b54
2 changed files with 4 additions and 25 deletions

View File

@ -2147,23 +2147,6 @@ static void eval_int36(struct opstack **stack, const void *userdata)
/*** END MESSAGE RENDERING ***/ /*** END MESSAGE RENDERING ***/
#include <util/nrmessage.h>
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, ...) int stream_printf(struct stream * out, const char *format, ...)
{ {
va_list args; va_list args;
@ -2226,8 +2209,6 @@ void register_reports(void)
register_argtype("items", var_free_resources, var_copy_items, VAR_VOIDPTR); register_argtype("items", var_free_resources, var_copy_items, VAR_VOIDPTR);
register_argtype("regions", var_free_regions, NULL, 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 */ /* register functions that turn message contents to readable strings */
add_function("alliance", &eval_alliance); add_function("alliance", &eval_alliance);
add_function("region", &eval_region); add_function("region", &eval_region);

View File

@ -71,7 +71,7 @@ void opstack_push(opstack ** stackp, variant data)
** static buffer malloc ** static buffer malloc
**/ **/
#define BBUFSIZE 0x20000 #define BBUFSIZE 0x10000
static struct { static struct {
char *begin; char *begin;
char *end; char *end;
@ -81,16 +81,13 @@ static struct {
char *balloc(size_t size) char *balloc(size_t size)
{ {
static int init = 0; /* STATIC_XCALL: used across calls */ static int init = 0;
if (!init) { if (!init) {
init = 1; init = 1;
buffer.current = buffer.begin = malloc(BBUFSIZE * sizeof(char)); buffer.current = buffer.begin = malloc(BBUFSIZE * sizeof(char));
buffer.end = buffer.begin + BBUFSIZE; buffer.end = buffer.begin + BBUFSIZE;
} }
if (buffer.current + size > buffer.end) { assert(buffer.current + size <= buffer.end || !"balloc is out of memory");
/* out of memory! */
return NULL;
}
buffer.last = buffer.current; buffer.last = buffer.current;
buffer.current += size; buffer.current += size;
return buffer.last; return buffer.last;
@ -99,6 +96,7 @@ char *balloc(size_t size)
void bfree(char *c) void bfree(char *c)
/* only release this memory if it was part of the last allocation /* only release this memory if it was part of the last allocation
* that's a joke, but who cares. * that's a joke, but who cares.
* I'm afraid I don't get the joke.
*/ */
{ {
if (c >= buffer.last && c < buffer.current) if (c >= buffer.last && c < buffer.current)