X-Git-Url: https://plomlompom.com/repos/berlin_corona.txt?a=blobdiff_plain;f=src%2Fclient%2Fcommand_db.c;h=00a907b3c9d73470ebf781a38d156e48f3930678;hb=3a5db435e5dc6422e559033fbdf9b64c8d8567c9;hp=27a3b6dc8d942552019a42e10c876daabc457ada;hpb=37fb9ef76174a83e27dd27a3250f4be5542e7452;p=plomrogue diff --git a/src/client/command_db.c b/src/client/command_db.c index 27a3b6d..00a907b 100644 --- a/src/client/command_db.c +++ b/src/client/command_db.c @@ -14,6 +14,7 @@ #include "cleanup.h" /* set_cleanup_flag() */ #include "world.h" /* global world */ +#include "misc.h" /* Point "ch_ptr" to next strtok() string in "line" delimited by "delim".*/ @@ -79,13 +80,8 @@ extern void init_command_db() char * arg_string = strtok(NULL, delim); cmd.arg = arg_string[0]; copy_tokenized_string(NULL, &cmd.dsc_long, "\n"); - uint32_t old_size = i * sizeof(struct Command); - uint32_t new_size = old_size + sizeof(struct Command); - struct Command * new_cmds = try_malloc(new_size, f_name); - memcpy(new_cmds, world.commandDB.cmds, old_size); - new_cmds[i] = cmd; - free(world.commandDB.cmds); - world.commandDB.cmds = new_cmds; + array_append(i, sizeof(struct Command), (void *) &cmd, + (void **) &world.commandDB.cmds); i++; } try_fclose(file, f_name);