From c8d03c9ea3dac6173fb91e31000896a5b0f3472b Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 14 Feb 2021 20:47:12 +0100 Subject: [PATCH] fix inifile and tolua builds remove our custom assert header --- src/battle.c | 4 ++-- src/kernel/region.c | 5 ++--- src/kernel/save.c | 1 - src/move.c | 6 +++--- src/spells.c | 4 ++-- src/tests.c | 6 +++--- src/util/assert.h | 7 ------- src/util/base36.c | 4 ++-- src/util/language.c | 2 +- src/util/log.c | 2 -- src/util/translation.c | 4 ++-- src/util/umlaut.c | 2 +- tolua | 2 +- tools/CMakeLists.txt | 5 ++++- 14 files changed, 23 insertions(+), 31 deletions(-) delete mode 100644 src/util/assert.h diff --git a/src/battle.c b/src/battle.c index ff0544442..0d153e525 100644 --- a/src/battle.c +++ b/src/battle.c @@ -44,7 +44,6 @@ #include "attributes/otherfaction.h" /* util includes */ -#include "util/assert.h" #include "kernel/attrib.h" #include "util/base36.h" #include "util/language.h" @@ -60,6 +59,7 @@ #include /* libc includes */ +#include #include #include #include @@ -194,7 +194,7 @@ void battle_message_faction(battle * b, faction * f, struct message *m) assert(f); if (f->battles == NULL || f->battles->r != r) { struct bmsg *bm = (struct bmsg *)calloc(1, sizeof(struct bmsg)); - assert_alloc(bm); + assert(bm); bm->next = f->battles; f->battles = bm; bm->r = r; diff --git a/src/kernel/region.c b/src/kernel/region.c index a3681158e..6fade14fc 100644 --- a/src/kernel/region.c +++ b/src/kernel/region.c @@ -26,7 +26,6 @@ #include /* util includes */ -#include #include #include #include @@ -698,7 +697,7 @@ void r_setdemand(region * r, const luxury_type * ltype, int value) d = *dp; if (!d) { d = *dp = malloc(sizeof(struct demand)); - assert_alloc(d); + assert(d); d->next = NULL; d->type = ltype; } @@ -763,7 +762,7 @@ int rsettrees(const region * r, int ageclass, int value) region *region_create(int uid) { region *r = (region *)calloc(1, sizeof(region)); - assert_alloc(r); + assert(r); r->uid = uid; rhash_uid(r); return r; diff --git a/src/kernel/save.c b/src/kernel/save.c index 6a55aeb36..f83a87ef8 100644 --- a/src/kernel/save.c +++ b/src/kernel/save.c @@ -40,7 +40,6 @@ #include /* util includes */ -#include #include #include #include diff --git a/src/move.c b/src/move.c index 0da6e17e0..68b5a4118 100644 --- a/src/move.c +++ b/src/move.c @@ -55,7 +55,6 @@ #include "skill.h" /* util includes */ -#include #include #include #include @@ -70,6 +69,7 @@ #include /* libc includes */ +#include #include #include #include @@ -112,7 +112,7 @@ get_followers(unit * u, region * r, const region_list * route_end, while (a) { if (a->data.v == u) { follower *fnew = (follower *)malloc(sizeof(follower)); - assert_alloc(fnew); + assert(fnew); fnew->uf = uf; fnew->ut = u; fnew->route_end = route_end; @@ -1483,7 +1483,7 @@ static void var_create_regions(arg_regions *dst, const region_list * begin, int assert(size > 0); dst->nregions = size; dst->regions = (region **) malloc(sizeof(region *) * (size_t)size); - assert_alloc(dst->regions); + assert(dst->regions); for (i = 0, rsrc = begin; i != size; rsrc = rsrc->next, ++i) { dst->regions[i] = rsrc->data; } diff --git a/src/spells.c b/src/spells.c index 0433eefa2..e5f1a3b53 100644 --- a/src/spells.c +++ b/src/spells.c @@ -57,7 +57,6 @@ #include /* util includes */ -#include #include #include #include @@ -81,6 +80,7 @@ #include /* libc includes */ +#include #include #include #include @@ -1269,7 +1269,7 @@ add_ironweapon(const struct item_type *type, const struct item_type *rusty, float chance) { iron_weapon *iweapon = malloc(sizeof(iron_weapon)); - assert_alloc(iweapon); + assert(iweapon); iweapon->type = type; iweapon->rusty = rusty; iweapon->chance = chance; diff --git a/src/tests.c b/src/tests.c index 7972b3adb..24d742c9d 100644 --- a/src/tests.c +++ b/src/tests.c @@ -37,10 +37,10 @@ #include "util/stats.h" #include "util/param.h" #include "util/rand.h" -#include "util/assert.h" #include +#include #include #include #include @@ -367,7 +367,7 @@ ship_type * test_create_shiptype(const char * name) stype->damage = 1; if (!stype->construction) { stype->construction = calloc(1, sizeof(construction)); - assert_alloc(stype->construction); + assert(stype->construction); stype->construction->maxsize = 5; stype->construction->minskill = 1; stype->construction->reqsize = 1; @@ -448,7 +448,7 @@ spell * test_create_spell(void) sp = create_spell("testspell"); sp->components = (spell_component *)calloc(4, sizeof(spell_component)); - assert_alloc(sp->components); + assert(sp->components); sp->components[0].amount = 1; sp->components[0].type = get_resourcetype(R_SILVER); sp->components[0].cost = SPC_FIX; diff --git a/src/util/assert.h b/src/util/assert.h deleted file mode 100644 index 79abce73e..000000000 --- a/src/util/assert.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef UTIL_ASSERT_H -#define UTIL_ASSERT_H - -#include - -#define assert_alloc(expr) assert((expr) || !"out of memory") -#endif diff --git a/src/util/base36.c b/src/util/base36.c index edec82f62..dd5c55c79 100644 --- a/src/util/base36.c +++ b/src/util/base36.c @@ -1,7 +1,7 @@ #include "base36.h" -#include "log.h" #include +#include #include #include #include @@ -78,7 +78,7 @@ const char *itoab_r(int i, int base, char *s, size_t len) } } else { - log_error("static buffer exhausted, itoab(%d, %d)", i, base); + fprintf(stderr, "static buffer exhausted, itoab(%d, %d)", i, base); assert(i == 0 || !"itoab: static buffer exhausted"); } } diff --git a/src/util/language.c b/src/util/language.c index 72e7f84f3..131b7078e 100644 --- a/src/util/language.c +++ b/src/util/language.c @@ -66,7 +66,7 @@ locale *get_or_create_locale(const char *name) } } *lp = l = (locale *)calloc(1, sizeof(locale)); - assert_alloc(l); + assert(l); l->hashkey = hkey; l->name = str_strdup(name); l->index = nextlocaleindex++; diff --git a/src/util/log.c b/src/util/log.c index 2d91240bb..e8cf0e2fe 100644 --- a/src/util/log.c +++ b/src/util/log.c @@ -4,8 +4,6 @@ #include "strings.h" #include "unicode.h" -#include - #include #include #include diff --git a/src/util/translation.c b/src/util/translation.c index 3d794d920..89d83cd24 100644 --- a/src/util/translation.c +++ b/src/util/translation.c @@ -41,7 +41,7 @@ void opstack_push(opstack ** stackp, variant data) opstack *stack = *stackp; if (stack == NULL) { stack = (opstack *)malloc(sizeof(opstack)); - assert_alloc(stack); + assert(stack); stack->size = 2; stack->begin = malloc(sizeof(variant) * stack->size); stack->top = stack->begin; @@ -52,7 +52,7 @@ void opstack_push(opstack ** stackp, variant data) void *tmp; stack->size += stack->size; tmp = realloc(stack->begin, sizeof(variant) * stack->size); - assert_alloc(tmp); + assert(tmp); stack->begin = (variant *)tmp; stack->top = stack->begin + pos; } diff --git a/src/util/umlaut.c b/src/util/umlaut.c index 46e901994..0943e0485 100644 --- a/src/util/umlaut.c +++ b/src/util/umlaut.c @@ -176,7 +176,7 @@ void addtoken(tnode ** root, const char *str, variant id) index = lcs % NODEHASHSIZE; #endif ref = (tref *)malloc(sizeof(tref)); - assert_alloc(ref); + assert(ref); ref->wc = lcs; ref->node = node; ++node->refcount; diff --git a/tolua b/tolua index c36200dae..99ac2e060 160000 --- a/tolua +++ b/tolua @@ -1 +1 @@ -Subproject commit c36200dae924ffb6eab89b802801d807ff96bfd0 +Subproject commit 99ac2e060f32e92f378652a2a249f7e535232671 diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 75746be2c..3f60ba3ee 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -7,5 +7,8 @@ target_include_directories (inifile PRIVATE ${IniParser_INCLUDE_DIRS}) add_executable(gethash gethash.c) -add_executable(atoi36 atoi36.c ${CMAKE_SOURCE_DIR}/src/util/base36.c) +add_executable(atoi36 + atoi36.c + ${CMAKE_SOURCE_DIR}/src/util/base36.c + ) target_include_directories(atoi36 PRIVATE ${CMAKE_SOURCE_DIR}/src/util)