mirror of
https://github.com/Ed94/Odin.git
synced 2026-06-16 02:42:22 -07:00
Add SCOPED_TEMPORARY_BLOCK for temporary allocations within a block
This commit is contained in:
+4
-5
@@ -121,8 +121,8 @@ void check_init_variables(CheckerContext *ctx, Entity **lhs, isize lhs_count, Ar
|
||||
|
||||
// NOTE(bill): If there is a bad syntax error, rhs > lhs which would mean there would need to be
|
||||
// an extra allocation
|
||||
auto operands = array_make<Operand>(ctx->allocator, 0, 2*lhs_count);
|
||||
defer (array_free(&operands));
|
||||
SCOPED_TEMPORARY_BLOCK();
|
||||
auto operands = array_make<Operand>(temporary_allocator(), 0, 2*lhs_count);
|
||||
check_unpack_arguments(ctx, lhs, lhs_count, &operands, inits, true, false);
|
||||
|
||||
isize rhs_count = operands.count;
|
||||
@@ -317,7 +317,6 @@ void check_type_decl(CheckerContext *ctx, Entity *e, Ast *init_expr, Type *def)
|
||||
break;
|
||||
default:
|
||||
error(e->token, "Only struct types can have custom atom operations");
|
||||
gb_free(heap_allocator(), ac.atom_op_table);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -638,7 +637,7 @@ String handle_link_name(CheckerContext *ctx, Token token, String link_name, Stri
|
||||
error(token, "'link_name' and 'link_prefix' cannot be used together");
|
||||
} else {
|
||||
isize len = link_prefix.len + token.string.len;
|
||||
u8 *name = gb_alloc_array(ctx->allocator, u8, len+1);
|
||||
u8 *name = gb_alloc_array(permanent_allocator(), u8, len+1);
|
||||
gb_memmove(name, &link_prefix[0], link_prefix.len);
|
||||
gb_memmove(name+link_prefix.len, &token.string[0], token.string.len);
|
||||
name[len] = 0;
|
||||
@@ -975,7 +974,7 @@ void check_proc_group_decl(CheckerContext *ctx, Entity *pg_entity, DeclInfo *d)
|
||||
|
||||
ast_node(pg, ProcGroup, d->init_expr);
|
||||
|
||||
pge->entities = array_make<Entity*>(ctx->allocator, 0, pg->args.count);
|
||||
pge->entities = array_make<Entity*>(permanent_allocator(), 0, pg->args.count);
|
||||
|
||||
// NOTE(bill): This must be set here to prevent cycles in checking if someone
|
||||
// places the entity within itself
|
||||
|
||||
Reference in New Issue
Block a user