diff options
Diffstat (limited to 'asset.cpp')
-rw-r--r-- | asset.cpp | 14 |
1 files changed, 5 insertions, 9 deletions
@@ -8,7 +8,7 @@ extern "C" { } #define max_asset_types 32 -#define asset_scratch_size (1024 * 1024) +#define asset_scratch_size (1024) struct RLoader { char magic[4]; @@ -75,12 +75,6 @@ void Asset_Arena::init( p = pack_open(pack_name, arena); assert(p != 0); a = arena; - s = (Arena*)arena_alloc(a, sizeof *s); - init_arena( - s, - arena_alloc(a, asset_scratch_size), - asset_scratch_size - ); max_assets = max; assets = (Bucket*)arena_alloc(arena, max * sizeof(Bucket)); for (i = 0; i < max; i++) @@ -112,6 +106,8 @@ int Asset_Arena::bucket(const char* name) { Asset* Asset_Arena::load(const char* name) { char magic[4]; + char scratch[asset_scratch_size]; + Arena sa; Pack_File* f; int b = bucket(name); assert(b >= 0); @@ -122,8 +118,8 @@ Asset* Asset_Arena::load(const char* name) { pack_read(f, magic, 4); pack_seek(f, 0, seek_rel_start); Asset_Loader& loader = manager.get_loader(magic); - clear_arena(s); - Asset* asset = loader.load(a, s, name, f); + init_arena(&sa, scratch, sizeof scratch); + Asset* asset = loader.load(a, &sa, name, f); if (asset) { asset->loader = &loader; assets[b].name = dup_string(a, name); |