bug fix in pointer aligning function

This commit is contained in:
cozis
2022-04-19 01:55:39 +02:00
parent 8e3b4411ed
commit 1ec3d78ab6
2 changed files with 8 additions and 15 deletions
+4 -12
View File
@@ -11,24 +11,17 @@ static const struct {
const char *src; const char *src;
} tests[] = { } tests[] = {
TEST("null"), TEST("null"),
TEST("\t\n null \t\n"),
TEST("true"), TEST("true"),
TEST("\t\n true \t\n"),
TEST("false"), TEST("false"),
TEST("\t\n false \t\n"),
TEST("1"), TEST("1"),
TEST(" 1 "), TEST("100"),
TEST("1.0"),
TEST("100.111"),
TEST("[]"), TEST("[]"),
TEST("[1, 2, 3]"), TEST("[1, 2, 3]"),
TEST(" [ ] "),
TEST(" [ 1 , 2 , 3 ] "),
TEST("{}"), TEST("{}"),
TEST(" { } "),
TEST("{\"key\":5}"), TEST("{\"key\":5}"),
TEST("{\"key1\":5,\"key2\":3}"),
}; };
#undef TEST #undef TEST
@@ -82,7 +75,6 @@ int main()
if(json_strings_match(serialized, tests[i].src)) if(json_strings_match(serialized, tests[i].src))
{ {
//fprintf(stdout, "Passed.\n");
passed += 1; passed += 1;
} }
else else
+2 -1
View File
@@ -74,7 +74,7 @@ void xj_alloc_del(xj_alloc *alloc)
unsigned long long next_aligned(unsigned long long n) unsigned long long next_aligned(unsigned long long n)
{ {
return n & 7 ? n & ~7 : n; return (n & 7) ? (n & ~7) + 8 : n;
} }
void *xj_bpalloc(xj_alloc *alloc, int size) void *xj_bpalloc(xj_alloc *alloc, int size)
@@ -103,6 +103,7 @@ void *xj_bpalloc(xj_alloc *alloc, int size)
} }
void *addr = alloc->tail->body + alloc->tail_used; void *addr = alloc->tail->body + alloc->tail_used;
alloc->tail_used += size; alloc->tail_used += size;
return addr; return addr;