From 68aa903130c6f32bbf9d2ac8807ff8de1684d313 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 26 Jun 2014 21:48:01 -0700 Subject: [PATCH] make tests pass through valgrind introduce more #ifdef LOMEM to bitfield structs. --- src/json.test.c | 4 +++- src/kernel/battle.h | 16 ++++++++++++++++ src/kernel/order.c | 5 +++++ src/kernel/resources.h | 9 +++++++++ src/kernel/skills.h | 7 +++++++ 5 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/json.test.c b/src/json.test.c index 7c1027596..1c6d72d70 100644 --- a/src/json.test.c +++ b/src/json.test.c @@ -21,7 +21,9 @@ static char *strip(char *str) { for (; *b && isspace(*b); ++b) {}; for (e = b; *e && !isspace(*e); ++e) {}; while (*b) { - memcpy(s, b, e - b); + if (s!=b) { + memcpy(s, b, e - b); + } s += e - b; for (b = e; *b && isspace(*b); ++b) {}; for (e = b; *e && !isspace(*e); ++e) {}; diff --git a/src/kernel/battle.h b/src/kernel/battle.h index eb854caeb..95d869ff3 100644 --- a/src/kernel/battle.h +++ b/src/kernel/battle.h @@ -117,8 +117,13 @@ extern "C" { typedef struct weapon { int count, used; const struct weapon_type *type; +# ifdef LOMEM int attackskill:8; int defenseskill:8; +# else + int attackskill; + int defenseskill; +# endif } weapon; /*** fighter::person::flags ***/ @@ -165,6 +170,7 @@ extern "C" { int catmsg; /* Merkt sich, ob Katapultmessage schon generiert. */ struct person { int hp; /* Trefferpunkte der Personen */ +#ifdef LOMEM int attack:8; /* (Magie) Attackenbonus der Personen */ int defence:8; /* (Magie) Paradenbonus der Personen */ int damage:8; /* (Magie) Schadensbonus der Personen im Nahkampf */ @@ -174,6 +180,16 @@ extern "C" { int reload:4; /* Anzahl Runden, die die Waffe x noch laden muss. * dahinter steckt ein array[RL_MAX] wenn er min. eine hat. */ int last_action:4; /* In welcher Runde haben wir zuletzt etwas getan */ +#else + int attack; + int defence; + int damage; + int damage_rear; + int flags; + int speed; + int reload; + int last_action; +#endif struct weapon *missile; /* missile weapon */ struct weapon *melee; /* melee weapon */ } *person; diff --git a/src/kernel/order.c b/src/kernel/order.c index 2ec616eb6..8154f3cda 100644 --- a/src/kernel/order.c +++ b/src/kernel/order.c @@ -45,8 +45,13 @@ static int nlocales = 0; typedef struct order_data { char *_str; +# ifdef LOMEM int _refcount:20; int _lindex:4; +# else + int _refcount; + int _lindex; +# endif keyword_t _keyword; } order_data; diff --git a/src/kernel/resources.h b/src/kernel/resources.h index d2c229657..ace16a177 100644 --- a/src/kernel/resources.h +++ b/src/kernel/resources.h @@ -22,12 +22,21 @@ extern "C" { typedef struct rawmaterial { const struct rawmaterial_type *type; +#ifdef LOMEM int amount:16; int level:8; int flags:8; int base:8; int divisor:8; int startlevel:8; +#else + int amount; + int level; + int flags; + int base; + int divisor; + int startlevel; +#endif struct rawmaterial *next; } rawmaterial; diff --git a/src/kernel/skills.h b/src/kernel/skills.h index bc7300c02..5d8b3477f 100644 --- a/src/kernel/skills.h +++ b/src/kernel/skills.h @@ -25,10 +25,17 @@ extern "C" { #define SMF_RIDING (1<<2) /* Bonus für berittene - an der rasse */ typedef struct skill { +#ifdef LOMEM int id:8; unsigned int level:8; unsigned int weeks:8; unsigned int old:8; +#else + int id; + unsigned int level; + unsigned int weeks; + unsigned int old; +#endif } skill; typedef int (*skillmod_fun) (const struct unit *, const struct region *,