From 37c25a56195ebbe422358fcf537d631ef6445450 Mon Sep 17 00:00:00 2001 From: Markus Mittendrein Date: Tue, 2 Oct 2018 16:03:48 +0200 Subject: Add a more flexible enum to choose the memory management mode for setEntryData instead of the freeData boolean --- src/cc4group.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/cc4group.h') diff --git a/src/cc4group.h b/src/cc4group.h index a6dcd37..82eddf6 100644 --- a/src/cc4group.h +++ b/src/cc4group.h @@ -63,6 +63,12 @@ typedef struct { CC4Group_TmpMemoryStrategy Auto; } const TmpMemoryStrategies; + struct { + int Take; // cc4group will free the data when its not needed anymore; e.g. in the destructor or when setting the file's data again + int Copy; // cc4group will copy the data to use it + int Reference; // cc4group will use the data as is (i.e. store the pointer and use it); the caller must guarantee it's validity throughout the groups lifetime (or until the file's data is set to a new pointer) + } const MemoryManagement; + void (*setTmpMemoryStrategy)(const CC4Group_TmpMemoryStrategy strategy); // group metadata handling @@ -83,7 +89,7 @@ typedef struct { bool (*createFile)(CC4Group* const this, const char* const path); // ownership of the data is taken by the group if freeData is true // if freeData is false, the caller must guarantee that the pointer is valid as long as it is used in the group (i.e. until the pointer is changed through another call to setEntryData or the group is destructed) - bool (*setEntryData)(CC4Group* const this, const char* const entryPath, const void* const data, size_t const size, bool const freeData); + bool (*setEntryData)(CC4Group* const this, const char* const entryPath, const void* const data, size_t const size, int const memoryManagementMode); } const CC4Group_API; #ifndef CC4GROUP_DYNAMIC_LOAD -- cgit v1.2.3-54-g00ecf