Skip to content

Commit

Permalink
add mem parent and heap to image allocator
Browse files Browse the repository at this point in the history
  • Loading branch information
recp committed Oct 16, 2023
1 parent 47901fd commit 182c299
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
8 changes: 6 additions & 2 deletions include/ak/image.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,15 @@ void
ak_imageLoad(AkImage * __restrict image);

/* Loader Configurator */
typedef void* (*AkImageLoadFromFileFn)(const char * __restrict path,
typedef void* (*AkImageLoadFromFileFn)(AkHeap * __restrict heap,
void * __restrict memparent,
const char * __restrict path,
int * __restrict width,
int * __restrict height,
int * __restrict components);
typedef void* (*AkImageLoadFromMemoryFn)(const char * __restrict data,
typedef void* (*AkImageLoadFromMemoryFn)(AkHeap * __restrict heap,
void * __restrict memparent,
const char * __restrict data,
size_t len,
int * __restrict width,
int * __restrict height,
Expand Down
3 changes: 2 additions & 1 deletion include/ak/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ typedef struct AkObject {
char data[];
} AkObject;

#define ak_objGet(OBJ) ((OBJ)->pData)
#define ak_objGetOrNull(OBJ) (OBJ ? (OBJ)->pData : NULL)
#define ak_objGet(OBJ) ((OBJ)->pData)
#define ak_allocator ak_mem_allocator()

typedef struct AkHeapAllocator {
Expand Down
6 changes: 4 additions & 2 deletions src/image/image.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ ak_imageLoad(AkImage * __restrict image) {
return;

path = ak_fullpath(doc, initFrom->ref, pathbuf);
data = ak__img_conf.loadFromFile(path, &x, &y, &ch);
data = ak__img_conf.loadFromFile(heap, image, path, &x, &y, &ch);
if (!data)
return;

Expand All @@ -94,7 +94,9 @@ ak_imageLoad(AkImage * __restrict image) {
if (!ak__img_conf.loadFromMemory)
return;

data = ak__img_conf.loadFromMemory(initFrom->buff->data,
data = ak__img_conf.loadFromMemory(heap,
image,
initFrom->buff->data,
(int)initFrom->buff->length,
&x, &y, &ch);

Expand Down

0 comments on commit 182c299

Please sign in to comment.