Mercurial > molko
diff libmlk-rpg/mlk/rpg/map-file.c @ 442:9c3b3935f0aa
core: rework allocations
author | David Demelier <markand@malikania.fr> |
---|---|
date | Thu, 03 Nov 2022 21:09:25 +0100 |
parents | 25a56ca53ac2 |
children | 773a082f0b91 |
line wrap: on
line diff
--- a/libmlk-rpg/mlk/rpg/map-file.c Mon Oct 24 21:29:39 2022 +0200 +++ b/libmlk-rpg/mlk/rpg/map-file.c Thu Nov 03 21:09:25 2022 +0100 @@ -66,7 +66,7 @@ * The next line after a layer declaration is a list of plain integer * that fill the layer tiles. */ - if (!(ctx->mf->layers[layer_type].tiles = mlk_alloc_array0(amount, sizeof (unsigned short)))) + if (!(ctx->mf->layers[layer_type].tiles = mlk_alloc_new0(amount, sizeof (unsigned short)))) return -1; for (int tile; fscanf(ctx->fp, "%d\n", &tile) && current < amount; ++current) @@ -275,7 +275,7 @@ int ret = 0; memset(map, 0, sizeof (*map)); - mlk_alloc_pool_init(&file->blocks, sizeof (*map->blocks), NULL); + mlk_alloc_pool_init(&file->blocks, 16, sizeof (*map->blocks), NULL); if (!(ctx.fp = fopen(path, "r"))) goto fail; @@ -301,9 +301,9 @@ { assert(file); - free(file->layers[0].tiles); - free(file->layers[1].tiles); - free(file->layers[2].tiles); + mlk_alloc_free(file->layers[0].tiles); + mlk_alloc_free(file->layers[1].tiles); + mlk_alloc_free(file->layers[2].tiles); tileset_file_finish(&file->tileset_file); mlk_alloc_pool_finish(&file->blocks);