Refactor and fix up a lot of code

Don't tell the boss I forgot a couple of free()s...
This commit is contained in:
Jeremy Baxter 2023-11-26 17:13:41 +13:00
parent fe38efac42
commit 290289cbf5
12 changed files with 175 additions and 335 deletions

21
util.h
View file

@ -1,22 +1,17 @@
#ifndef _UTIL_H_
#define _UTIL_H_
#include <string.h>
#include <lua.h>
#define byte char
#define ubyte unsigned char
#define LFAIL_RET 2
#define streq(s1, s2) (strcmp((s1), (s2)) == 0)
#define newoverride(L, lib, libname) \
lua_getglobal(L, libname); \
for (int i = 0; lib[i].name != NULL; i++) { \
lua_pushcfunction(L, lib[i].func); \
lua_setfield(L, -2, lib[i].name); \
}
int lfail(lua_State *, const char *);
int lfail(lua_State *);
int lfailm(lua_State *, const char *);
#ifndef BSD
size_t strlcat(char *, const char *, size_t);
size_t strlcpy(char *, const char *, size_t);
#endif
void strprepend(char *, const char *);
#endif