Revert "Use scope-based memory management for malloc, free, open, close, etc."

This commit introduced a lot of changes and seems to have caused a few
issues, including breaking crc32 generation. Revert it for now with the
intention to reimplement some of the improvements.

This reverts commit 9d7600df51.
This commit is contained in:
Caleb Connolly
2023-06-23 13:30:08 +01:00
parent 20572c1417
commit 75e30f8d09
5 changed files with 344 additions and 328 deletions

View File

@@ -41,23 +41,17 @@ bool isslotnum(const char* str)
return strspn(str, "01") == strlen(str);
}
static void unexpectedSlot(const char *arg)
{
fprintf(stderr, "Expected slot not '%s'\n", arg);
exit(1);
}
unsigned parseSlot(const char* arg)
{
char *end;
int slot;
if (!isslot(arg))
unexpectedSlot(arg);
if (!isslot(arg)) {
goto fail;
}
if (isslotnum(arg)) {
slot = (int)strtol(arg, &end, 10);
if (end == arg)
unexpectedSlot(arg);
goto fail;
} else {
switch (arg[0]) {
case 'a':
@@ -69,11 +63,17 @@ unsigned parseSlot(const char* arg)
slot = 1;
break;
default:
unexpectedSlot(arg);
goto fail;
}
}
return (unsigned)slot;
fail:
fprintf(stderr,
"Expected slot not '%s'\n",
arg);
exit(1);
}
int usage()