diff options
Diffstat (limited to 'libs/utils/Pool.cpp')
-rw-r--r-- | libs/utils/Pool.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/libs/utils/Pool.cpp b/libs/utils/Pool.cpp new file mode 100644 index 0000000..8f18cb9 --- /dev/null +++ b/libs/utils/Pool.cpp @@ -0,0 +1,37 @@ +// +// Copyright 2010 The Android Open Source Project +// +// A simple memory pool. +// +#define LOG_TAG "Pool" + +//#define LOG_NDEBUG 0 + +#include <cutils/log.h> +#include <utils/Pool.h> + +#include <stdlib.h> + +namespace android { + +// TODO Provide a real implementation of a pool. This is just a stub for initial development. + +PoolImpl::PoolImpl(size_t objSize) : + mObjSize(objSize) { +} + +PoolImpl::~PoolImpl() { +} + +void* PoolImpl::allocImpl() { + void* ptr = malloc(mObjSize); + LOG_ALWAYS_FATAL_IF(ptr == NULL, "Cannot allocate new pool object."); + return ptr; +} + +void PoolImpl::freeImpl(void* obj) { + LOG_ALWAYS_FATAL_IF(obj == NULL, "Caller attempted to free NULL pool object."); + return free(obj); +} + +} // namespace android |