Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/org.eclipse.etrice.runtime.c/src/common/base/etMemory_VariableSize.c')
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/base/etMemory_VariableSize.c30
1 files changed, 10 insertions, 20 deletions
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/base/etMemory_VariableSize.c b/runtime/org.eclipse.etrice.runtime.c/src/common/base/etMemory_VariableSize.c
index dc0efad8d..dba017d79 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/base/etMemory_VariableSize.c
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/base/etMemory_VariableSize.c
@@ -17,20 +17,19 @@
#define DO_LOCK \
- if (self->lock!=NULL) { \
- self->lock->lockFct(self->lock->lockData); \
+ if (self->base.lock!=NULL) { \
+ self->base.lock->lockFct(self->base.lock->lockData); \
}
#define DO_UNLOCK \
- if (self->lock!=NULL) { \
- self->lock->unlockFct(self->lock->lockData); \
+ if (self->base.lock!=NULL) { \
+ self->base.lock->unlockFct(self->base.lock->lockData); \
}
typedef struct etVariableSizeMemory {
etMemory base; /** the "base class" */
etUInt8* current; /**< next free position on the heap */
- etLock* lock; /**< user supplied lock functions */
} etVariableSizeMemory;
@@ -71,20 +70,18 @@ void etMemory_VariableSize_free(etMemory* heap, void* obj) {
*/
etMemory* etMemory_VariableSize_init(void* heap, etUInt32 size) {
etVariableSizeMemory* self = (etVariableSizeMemory*) heap;
- size_t data_size = MEM_CEIL(sizeof(etVariableSizeMemory));
+ etUInt32 data_size = MEM_CEIL(sizeof(etVariableSizeMemory));
+ etUInt32 actual_size = size - data_size;
etMemory* result = NULL;
ET_MSC_LOGGER_SYNC_ENTRY("etMemory", "init")
- if (size > data_size) {
- self->base.size = size;
- self->base.statistics.maxUsed = 0;
- self->base.statistics.nFailingRequests = 0;
- self->base.alloc = etMemory_VariableSize_alloc;
- self->base.free = etMemory_VariableSize_free;
+ if (heap!=NULL & size > data_size) {
+ result = &self->base;
+
+ etMemory_init(result, actual_size, etMemory_VariableSize_alloc, etMemory_VariableSize_free);
self->current = ((etUInt8*)self)+data_size;
- result = &self->base;
}
ET_MSC_LOGGER_SYNC_EXIT
@@ -95,10 +92,3 @@ etUInt8 etMemory_VariableSize_freeHeapMem(etMemory* mem) {
etVariableSizeMemory* self = (etVariableSizeMemory*) mem;
return ((etUInt8*) self) + self->base.size - self->current;
}
-
-void etMemory_VariableSize_setUserLock(etMemory* mem, etLock* lock) {
- etVariableSizeMemory* self = (etVariableSizeMemory*) mem;
- ET_MSC_LOGGER_SYNC_ENTRY("etMemory_VariableSize", "setUserLock")
- self->lock = lock;
- ET_MSC_LOGGER_SYNC_EXIT
-}

Back to the top