formatted license comment
This commit is contained in:
parent
db5a728846
commit
0ffdb8c3ac
30 changed files with 16218 additions and 14914 deletions
10
core/arena.c
10
core/arena.c
|
|
@ -1,11 +1,11 @@
|
|||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
/* SPDX-License-Identifier:BSD-3-Clause */
|
||||
#include "arena.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
struct arena_allocator *arena_init(usize size)
|
||||
{
|
||||
struct arena_allocator *allocator = (struct arena_allocator *) malloc(sizeof(struct arena_allocator));
|
||||
struct arena_allocator *allocator = (struct arena_allocator *)malloc(sizeof(struct arena_allocator));
|
||||
allocator->size = size;
|
||||
allocator->base = (usize) malloc(size);
|
||||
allocator->position = 0;
|
||||
|
|
@ -27,15 +27,15 @@ void *arena_alloc(struct arena_allocator *allocator, usize size)
|
|||
}
|
||||
void *ptr = (void *)(allocator->base + allocator->position);
|
||||
allocator->position += size;
|
||||
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void *arena_zalloc(struct arena_allocator *allocator, usize size)
|
||||
{
|
||||
void *ptr = arena_alloc(allocator, size);
|
||||
for (usize i=0; i < size; i++) {
|
||||
((u8 *)ptr)[i] = 0x0;
|
||||
for (usize i = 0; i < size; i++) {
|
||||
((u8 *) ptr)[i] = 0x0;
|
||||
}
|
||||
|
||||
return ptr;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue