From 58bc74b6fdd58e870e2bbb1503148f79f0726306 Mon Sep 17 00:00:00 2001 From: Markus Mittendrein Date: Sat, 16 Mar 2019 15:57:50 +0100 Subject: Add initCallback and deinitCallback for openWithReadCallback --- src/cc4group.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/cc4group.h') diff --git a/src/cc4group.h b/src/cc4group.h index cc04a4f..76a0970 100644 --- a/src/cc4group.h +++ b/src/cc4group.h @@ -37,6 +37,10 @@ typedef void* (*CC4Group_TmpMemoryStrategy)(CC4Group* const this, const size_t s // the pointer passed in will be handled as specified with the corresponding MemoryManagement typedef bool (*CC4Group_ReadCallback)(const void** const data, size_t* const size, void* const arg); +// can be used as initialization before and deinitialization after all necessary calls to a read callback are made; for instance for buffer allocation and deletion +// the callback should return true on success and false on failure +typedef bool (*CC4Group_ReadSetupCallback)(void* const arg); + typedef struct { CC4Group* (*new)(void); bool (*create)(CC4Group* const this); @@ -60,8 +64,8 @@ typedef struct { // the file must have been opened with read access; also be aware that the file must be opened with binary mode on windows bool (*openFilePointer)(CC4Group* const this, FILE* fd); - // opens a group and calls the callback to get the group data - bool (*openWithReadCallback)(CC4Group* const this, CC4Group_ReadCallback const callback, void* const callbackArg, int const memoryManagement); + // opens a group and calls the callback to get the group data; initCallback is called before readCallback is called and deinitCallback is called after all read operations are done; initCallback and deinitCallback may be NULL if they should not be used + bool (*openWithReadCallback)(CC4Group* const this, CC4Group_ReadCallback const readCallback, void* const callbackArg, int const memoryManagement, CC4Group_ReadSetupCallback const initCallback, CC4Group_ReadSetupCallback const deinitCallback); bool (*save)(CC4Group* const this, const char* const path); bool (*saveOverwrite)(CC4Group* const this, const char* const path); -- cgit v1.2.3-54-g00ecf