Fix for namespace swapping

This commit is contained in:
2023-07-20 01:03:31 -04:00
parent 5efd14322e
commit 4d5cbd3e8d
10 changed files with 81 additions and 83 deletions

View File

@ -9,7 +9,7 @@ namespace Global
namespace Memory
{
zpl_arena Global_Arena {};
void setup()
{
zpl_arena_init_from_allocator( & Global_Arena, zpl_heap(), Initial_Reserve );
@ -19,16 +19,16 @@ namespace Memory
zpl_assert_crash( "Failed to reserve memory for Tests:: Global_Arena" );
}
}
void resize( uw new_size )
{
void* new_memory = zpl_resize( zpl_heap(), Global_Arena.physical_start, Global_Arena.total_size, new_size );
void* new_memory = zpl_resize( zpl_heap(), Global_Arena.physical_start, Global_Arena.total_size, new_size );
if ( new_memory == nullptr )
{
fatal("Failed to resize global arena!");
}
Global_Arena.physical_start = new_memory;
Global_Arena.total_size = new_size;
}
@ -36,7 +36,7 @@ namespace Memory
void cleanup()
{
zpl_arena_free( & Global_Arena);
}
}
}
@ -44,7 +44,7 @@ bool opts_custom_add(zpl_opts* opts, zpl_opts_entry *t, char* b)
{
if (t->type != ZPL_OPTS_STRING)
{
return false;
return false;
}
t->text = zpl_string_append_length(t->text, " ", 1);
@ -53,23 +53,23 @@ bool opts_custom_add(zpl_opts* opts, zpl_opts_entry *t, char* b)
return true;
}
b32 opts_custom_compile(zpl_opts *opts, int argc, char **argv)
b32 opts_custom_compile(zpl_opts *opts, int argc, char **argv)
{
zpl_b32 had_errors = false;
for (int i = 1; i < argc; ++i)
for (int i = 1; i < argc; ++i)
{
char* arg = argv[i];
if (*arg)
if (*arg)
{
arg = (char*)zpl_str_trim(arg, false);
if (*arg == '-')
if (*arg == '-')
{
zpl_opts_entry* entry = 0;
zpl_b32 checkln = false;
if ( *(arg + 1) == '-')
if ( *(arg + 1) == '-')
{
checkln = true;
++arg;
@ -83,15 +83,15 @@ b32 opts_custom_compile(zpl_opts *opts, int argc, char **argv)
entry = zpl__opts_find(opts, b, (e - b), checkln);
if (entry)
if (entry)
{
char *ob = b;
b = e;
/**/
if (*e == '=')
/**/
if (*e == '=')
{
if (entry->type == ZPL_OPTS_FLAG)
if (entry->type == ZPL_OPTS_FLAG)
{
*e = '\0';
zpl__opts_push_error(opts, ob, ZPL_OPTS_ERR_EXTRA_VALUE);
@ -101,14 +101,14 @@ b32 opts_custom_compile(zpl_opts *opts, int argc, char **argv)
}
b = e = e + 1;
}
else if (*e == '\0')
}
else if (*e == '\0')
{
char *sp = argv[i+1];
if (sp && *sp != '-' && (zpl_array_count(opts->positioned) < 1 || entry->type != ZPL_OPTS_FLAG))
if (sp && *sp != '-' && (zpl_array_count(opts->positioned) < 1 || entry->type != ZPL_OPTS_FLAG))
{
if (entry->type == ZPL_OPTS_FLAG)
if (entry->type == ZPL_OPTS_FLAG)
{
zpl__opts_push_error(opts, b, ZPL_OPTS_ERR_EXTRA_VALUE);
had_errors = true;
@ -119,10 +119,10 @@ b32 opts_custom_compile(zpl_opts *opts, int argc, char **argv)
arg = sp;
b = e = sp;
++i;
}
else
}
else
{
if (entry->type != ZPL_OPTS_FLAG)
if (entry->type != ZPL_OPTS_FLAG)
{
zpl__opts_push_error(opts, ob, ZPL_OPTS_ERR_MISSING_VALUE);
had_errors = true;
@ -145,20 +145,20 @@ b32 opts_custom_compile(zpl_opts *opts, int argc, char **argv)
opts_custom_add(opts, entry, b );
}
}
}
else
}
else
{
zpl__opts_push_error(opts, b, ZPL_OPTS_ERR_OPTION);
had_errors = true;
}
}
else if (zpl_array_count(opts->positioned))
}
else if (zpl_array_count(opts->positioned))
{
zpl_opts_entry *l = zpl_array_back(opts->positioned);
zpl_array_pop(opts->positioned);
zpl__opts_set_value(opts, l, arg);
}
else
}
else
{
zpl__opts_push_error(opts, arg, ZPL_OPTS_ERR_VALUE);
had_errors = true;