fix inifile and tolua builds

remove our custom assert header
This commit is contained in:
Enno Rehling 2021-02-14 20:47:12 +01:00
parent e156a65779
commit c8d03c9ea3
14 changed files with 23 additions and 31 deletions

View File

@ -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 <selist.h>
/* libc includes */
#include <assert.h>
#include <ctype.h>
#include <limits.h>
#include <math.h>
@ -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;

View File

@ -26,7 +26,6 @@
#include <spells/regioncurse.h>
/* util includes */
#include <util/assert.h>
#include <kernel/attrib.h>
#include <kernel/gamedata.h>
#include <util/strings.h>
@ -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;

View File

@ -40,7 +40,6 @@
#include <triggers/shock.h>
/* util includes */
#include <util/assert.h>
#include <kernel/attrib.h>
#include <util/base36.h>
#include <kernel/event.h>

View File

@ -55,7 +55,6 @@
#include "skill.h"
/* util includes */
#include <util/assert.h>
#include <util/base36.h>
#include <util/language.h>
#include <util/lists.h>
@ -70,6 +69,7 @@
#include <storage.h>
/* libc includes */
#include <assert.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
@ -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;
}

View File

@ -57,7 +57,6 @@
#include <kernel/unit.h>
/* util includes */
#include <util/assert.h>
#include <kernel/attrib.h>
#include <util/base36.h>
#include <kernel/event.h>
@ -81,6 +80,7 @@
#include <storage.h>
/* libc includes */
#include <assert.h>
#include <ctype.h>
#include <math.h>
#include <stdio.h>
@ -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;

View File

@ -37,10 +37,10 @@
#include "util/stats.h"
#include "util/param.h"
#include "util/rand.h"
#include "util/assert.h"
#include <CuTest.h>
#include <assert.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
@ -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;

View File

@ -1,7 +0,0 @@
#ifndef UTIL_ASSERT_H
#define UTIL_ASSERT_H
#include <assert.h>
#define assert_alloc(expr) assert((expr) || !"out of memory")
#endif

View File

@ -1,7 +1,7 @@
#include "base36.h"
#include "log.h"
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
@ -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");
}
}

View File

@ -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++;

View File

@ -4,8 +4,6 @@
#include "strings.h"
#include "unicode.h"
#include <critbit.h>
#include <assert.h>
#include <errno.h>
#include <limits.h>

View File

@ -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;
}

View File

@ -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;

2
tolua

@ -1 +1 @@
Subproject commit c36200dae924ffb6eab89b802801d807ff96bfd0
Subproject commit 99ac2e060f32e92f378652a2a249f7e535232671

View File

@ -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)