avoid more void pointer arithmetic
This commit is contained in:
parent
fedb36ed89
commit
ec8249513c
1 changed files with 3 additions and 3 deletions
|
|
@ -30,7 +30,7 @@ SLOB *slobinit(void *mem, size_t size)
|
||||||
|
|
||||||
slob = mem;
|
slob = mem;
|
||||||
slob->size = size - sizeof(SLOB);
|
slob->size = size - sizeof(SLOB);
|
||||||
slob->head = mem + sizeof(SLOB);
|
slob->head = (struct block *)((uint8_t *)mem + sizeof(SLOB));
|
||||||
slob->head->alloc.size = slob->size - sizeof(struct alloc);
|
slob->head->alloc.size = slob->size - sizeof(struct alloc);
|
||||||
slob->head->next = NULL;
|
slob->head->next = NULL;
|
||||||
|
|
||||||
|
|
@ -70,7 +70,7 @@ void *sloballoc(SLOB *slob, size_t size)
|
||||||
|
|
||||||
void slobfree(SLOB *slob, void *a_)
|
void slobfree(SLOB *slob, void *a_)
|
||||||
{
|
{
|
||||||
struct alloc *a = a_ - sizeof(struct alloc);
|
struct alloc *a = (struct alloc *)((uint8_t *)a_ - sizeof(struct alloc));
|
||||||
struct block *b, **p, *left=NULL, *right=NULL, **rightp=NULL;
|
struct block *b, **p, *left=NULL, *right=NULL, **rightp=NULL;
|
||||||
|
|
||||||
// sanity check: a lies inside slob
|
// sanity check: a lies inside slob
|
||||||
|
|
@ -203,7 +203,7 @@ HAllocator *h_sloballoc(void *mem, size_t size)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
HAllocator *mm = mem;
|
HAllocator *mm = mem;
|
||||||
SLOB *slob = slobinit(mem + sizeof(HAllocator), size - sizeof(HAllocator));
|
SLOB *slob = slobinit((uint8_t *)mem + sizeof(HAllocator), size - sizeof(HAllocator));
|
||||||
if(!slob)
|
if(!slob)
|
||||||
return NULL;
|
return NULL;
|
||||||
assert(slob == (SLOB *)(mm+1));
|
assert(slob == (SLOB *)(mm+1));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue