diff --git a/distr/flecs.c b/distr/flecs.c index e8b5ac455..1a408490c 100644 --- a/distr/flecs.c +++ b/distr/flecs.c @@ -20662,8 +20662,13 @@ ecs_entities_t ecs_get_entities( ecs_flags32_t ecs_world_get_flags( const ecs_world_t *world) { - flecs_poly_assert(world, ecs_world_t); - return world->flags; + if (flecs_poly_is(world, ecs_world_t)) { + return world->flags; + } else { + flecs_poly_assert(world, ecs_stage_t); + const ecs_stage_t *stage = (const ecs_stage_t*)world; + return stage->world->flags; + } } /** @@ -29984,7 +29989,7 @@ void flecs_hashmap_fini( ecs_hm_bucket_t *bucket = ecs_map_ptr(&it); ecs_vec_fini(a, &bucket->keys, map->key_size); ecs_vec_fini(a, &bucket->values, map->value_size); -#ifdef FLECS_SANITIZE +#if defined(FLECS_SANITIZE) || defined(FLECS_USE_OS_ALLOC) flecs_bfree(&map->bucket_allocator, bucket); #endif } @@ -30439,7 +30444,7 @@ void ecs_map_fini( } bool sanitize = false; -#ifdef FLECS_SANITIZE +#if defined(FLECS_SANITIZE) || defined(FLECS_USE_OS_ALLOC) sanitize = true; #endif @@ -71024,7 +71029,9 @@ ecs_iter_t ecs_query_iter( if (cache) { /* If monitors changed, do query rematching */ ecs_flags32_t flags = q->flags; - if (!(world->flags & EcsWorldReadonly) && flags & EcsQueryHasRefs) { + if (!(ecs_world_get_flags(world) & EcsWorldReadonly) && + (flags & EcsQueryHasRefs)) + { flecs_eval_component_monitors(q->world); } } diff --git a/distr/flecs.h b/distr/flecs.h index 7c4b9951e..f7947fd65 100644 --- a/distr/flecs.h +++ b/distr/flecs.h @@ -265,7 +265,7 @@ * When enabled, Flecs will use the OS allocator provided in the OS API directly * instead of the builtin block allocator. This can decrease memory utilization * as memory will be freed more often, at the cost of decreased performance. */ -#define FLECS_USE_OS_ALLOC +// #define FLECS_USE_OS_ALLOC /** @def FLECS_ID_DESC_MAX * Maximum number of ids to add ecs_entity_desc_t / ecs_bulk_desc_t */ diff --git a/include/flecs.h b/include/flecs.h index ec96077c2..027abc239 100644 --- a/include/flecs.h +++ b/include/flecs.h @@ -263,7 +263,7 @@ * When enabled, Flecs will use the OS allocator provided in the OS API directly * instead of the builtin block allocator. This can decrease memory utilization * as memory will be freed more often, at the cost of decreased performance. */ -#define FLECS_USE_OS_ALLOC +// #define FLECS_USE_OS_ALLOC /** @def FLECS_ID_DESC_MAX * Maximum number of ids to add ecs_entity_desc_t / ecs_bulk_desc_t */ diff --git a/src/datastructures/hashmap.c b/src/datastructures/hashmap.c index 987e9e6a6..e60c39ce2 100644 --- a/src/datastructures/hashmap.c +++ b/src/datastructures/hashmap.c @@ -53,7 +53,7 @@ void flecs_hashmap_fini( ecs_hm_bucket_t *bucket = ecs_map_ptr(&it); ecs_vec_fini(a, &bucket->keys, map->key_size); ecs_vec_fini(a, &bucket->values, map->value_size); -#ifdef FLECS_SANITIZE +#if defined(FLECS_SANITIZE) || defined(FLECS_USE_OS_ALLOC) flecs_bfree(&map->bucket_allocator, bucket); #endif } diff --git a/src/datastructures/map.c b/src/datastructures/map.c index 271dcfd25..cda7b1921 100644 --- a/src/datastructures/map.c +++ b/src/datastructures/map.c @@ -243,7 +243,7 @@ void ecs_map_fini( } bool sanitize = false; -#ifdef FLECS_SANITIZE +#if defined(FLECS_SANITIZE) || defined(FLECS_USE_OS_ALLOC) sanitize = true; #endif diff --git a/src/query/engine/eval_iter.c b/src/query/engine/eval_iter.c index 052955dda..7e2be7789 100644 --- a/src/query/engine/eval_iter.c +++ b/src/query/engine/eval_iter.c @@ -379,7 +379,9 @@ ecs_iter_t ecs_query_iter( if (cache) { /* If monitors changed, do query rematching */ ecs_flags32_t flags = q->flags; - if (!(world->flags & EcsWorldReadonly) && flags & EcsQueryHasRefs) { + if (!(ecs_world_get_flags(world) & EcsWorldReadonly) && + (flags & EcsQueryHasRefs)) + { flecs_eval_component_monitors(q->world); } } diff --git a/src/world.c b/src/world.c index cbe66941c..ab2008ea5 100644 --- a/src/world.c +++ b/src/world.c @@ -2400,6 +2400,11 @@ ecs_entities_t ecs_get_entities( ecs_flags32_t ecs_world_get_flags( const ecs_world_t *world) { - flecs_poly_assert(world, ecs_world_t); - return world->flags; + if (flecs_poly_is(world, ecs_world_t)) { + return world->flags; + } else { + flecs_poly_assert(world, ecs_stage_t); + const ecs_stage_t *stage = (const ecs_stage_t*)world; + return stage->world->flags; + } }