From f7041112f179aa79b6e315e7d57afbf76d3cd8bb Mon Sep 17 00:00:00 2001 From: Franklin Wei Date: Fri, 25 Dec 2015 17:28:09 -0500 Subject: implement child lookup via hash table --- src/room.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/room.c') diff --git a/src/room.c b/src/room.c index fb8d138..18fd37e 100644 --- a/src/room.c +++ b/src/room.c @@ -125,11 +125,17 @@ bool world_load(const char *fname, const struct roomdata_t *data, size_t data_sz if(magic != WORLD_MAGIC) return false; read(fd, &world_sz, sizeof(world_sz)); + if(world) + /* possible memory leak here as strings allocated inside of world + aren't freed. avoided by loading only one world per instance */ free(world); + if(world_sz != data_sz) return false; + world = calloc(world_sz, sizeof(struct room_t)); + for(unsigned i = 0; i < world_sz; ++i) { world[i].id = read_roomid(fd); -- cgit v1.1