summaryrefslogtreecommitdiff
path: root/src/common/ers.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/ers.c')
-rw-r--r--src/common/ers.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/src/common/ers.c b/src/common/ers.c
index c8a11d2a9..489d8f7ae 100644
--- a/src/common/ers.c
+++ b/src/common/ers.c
@@ -83,19 +83,19 @@ typedef struct ers_cache
// Free objects count
unsigned int Free;
-
+
// Used blocks count
unsigned int Used;
-
+
// Objects in-use count
unsigned int UsedObjs;
-
+
// Default = ERS_BLOCK_ENTRIES, can be adjusted for performance for individual cache sizes.
unsigned int ChunkSize;
-
+
// Misc options, some options are shared from the instance
enum ERSOptions Options;
-
+
// Linked list
struct ers_cache *Next, *Prev;
} ers_cache_t;
@@ -103,10 +103,10 @@ typedef struct ers_cache
struct ers_instance_t {
// Interface to ERS
struct eri VTable;
-
+
// Name, used for debugging purposes
char *Name;
-
+
// Misc options
enum ERSOptions Options;
@@ -115,7 +115,7 @@ struct ers_instance_t {
// Count of objects in use, used for detecting memory leaks
unsigned int Count;
-
+
#ifdef DEBUG
/* for data analysis [Ind/Hercules] */
unsigned int Peak;
@@ -149,7 +149,7 @@ static ers_cache_t *ers_find_cache(unsigned int size, enum ERSOptions Options) {
cache->Max = 0;
cache->ChunkSize = ERS_BLOCK_ENTRIES;
cache->Options = (Options & ERS_CACHE_OPTIONS);
-
+
if (CacheList == NULL)
{
CacheList = cache;
@@ -181,7 +181,7 @@ static void ers_free_cache(ers_cache_t *cache, bool remove)
CacheList = cache->Next;
aFree(cache->Blocks);
-
+
aFree(cache);
}
@@ -216,7 +216,7 @@ static void *ers_obj_alloc_entry(ERS *self)
instance->Count++;
instance->Cache->UsedObjs++;
-
+
#ifdef DEBUG
if( instance->Count > instance->Peak )
instance->Peak = instance->Count;
@@ -240,7 +240,7 @@ static void ers_obj_free_entry(ERS *self, void *entry)
if( instance->Cache->Options & ERS_OPT_CLEAN )
memset((unsigned char*)reuse + sizeof(struct ers_list), 0, instance->Cache->ObjectSize - sizeof(struct ers_list));
-
+
reuse->Next = instance->Cache->ReuseList;
instance->Cache->ReuseList = reuse;
instance->Count--;
@@ -277,27 +277,27 @@ static void ers_obj_destroy(ERS *self)
if (instance->Next)
instance->Next->Prev = instance->Prev;
-
+
if (instance->Prev)
instance->Prev->Next = instance->Next;
else
InstanceList = instance->Next;
-
+
if( instance->Options & ERS_OPT_FREE_NAME )
aFree(instance->Name);
-
+
aFree(instance);
}
void ers_cache_size(ERS *self, unsigned int new_size) {
struct ers_instance_t *instance = (struct ers_instance_t *)self;
-
+
nullpo_retv(instance);
-
+
if( !(instance->Cache->Options&ERS_OPT_FLEX_CHUNK) ) {
ShowWarning("ers_cache_size: '%s' has adjusted its chunk size to '%d', however ERS_OPT_FLEX_CHUNK is missing!\n",instance->Name,new_size);
}
-
+
instance->Cache->ChunkSize = new_size;
}
@@ -321,7 +321,7 @@ ERS *ers_new(uint32 size, char *name, enum ERSOptions options)
instance->Options = options;
instance->Cache = ers_find_cache(size,instance->Options);
-
+
instance->Cache->ReferenceCount++;
if (InstanceList == NULL) {
@@ -384,7 +384,7 @@ void ers_report(void) {
**/
void ers_final(void) {
struct ers_instance_t *instance = InstanceList, *next;
-
+
while( instance ) {
next = instance->Next;
ers_obj_destroy((ERS*)instance);