parent
b7adb91784
commit
c6095b96d9
|
@ -6,29 +6,39 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
// NOTE: I guess this marker is used as a type discriminator for implementing
|
||||
// nested dictionaries. That's why every dictionary-related function starts
|
||||
// with a check for this value.
|
||||
#define DICTIONARY_MARKER 0xFEBAFEBA
|
||||
|
||||
static void* dictionaryMallocDefaultImpl(size_t size);
|
||||
static void* dictionaryReallocDefaultImpl(void* ptr, size_t newSize);
|
||||
static void dictionaryFreeDefaultImpl(void* ptr);
|
||||
static int dictionaryFindIndexForKey(Dictionary* dictionary, const char* key, int* index);
|
||||
|
||||
// 0x51E408
|
||||
MallocProc* gDictionaryMallocProc = dictionaryMallocDefaultImpl;
|
||||
static MallocProc* gDictionaryMallocProc = dictionaryMallocDefaultImpl;
|
||||
|
||||
// 0x51E40C
|
||||
ReallocProc* gDictionaryReallocProc = dictionaryReallocDefaultImpl;
|
||||
static ReallocProc* gDictionaryReallocProc = dictionaryReallocDefaultImpl;
|
||||
|
||||
// 0x51E410
|
||||
FreeProc* gDictionaryFreeProc = dictionaryFreeDefaultImpl;
|
||||
static FreeProc* gDictionaryFreeProc = dictionaryFreeDefaultImpl;
|
||||
|
||||
// 0x4D9B90
|
||||
void* dictionaryMallocDefaultImpl(size_t size)
|
||||
static void* dictionaryMallocDefaultImpl(size_t size)
|
||||
{
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
// 0x4D9B98
|
||||
void* dictionaryReallocDefaultImpl(void* ptr, size_t newSize)
|
||||
static void* dictionaryReallocDefaultImpl(void* ptr, size_t newSize)
|
||||
{
|
||||
return realloc(ptr, newSize);
|
||||
}
|
||||
|
||||
// 0x4D9BA0
|
||||
void dictionaryFreeDefaultImpl(void* ptr)
|
||||
static void dictionaryFreeDefaultImpl(void* ptr)
|
||||
{
|
||||
free(ptr);
|
||||
}
|
||||
|
@ -127,7 +137,7 @@ int dictionaryFree(Dictionary* dictionary)
|
|||
// specifies an insertion point for given key.
|
||||
//
|
||||
// 0x4D9CC4
|
||||
int dictionaryFindIndexForKey(Dictionary* dictionary, const char* key, int* indexPtr)
|
||||
static int dictionaryFindIndexForKey(Dictionary* dictionary, const char* key, int* indexPtr)
|
||||
{
|
||||
if (dictionary->marker != DICTIONARY_MARKER) {
|
||||
return -1;
|
||||
|
|
|
@ -3,11 +3,6 @@
|
|||
|
||||
#include "memory_defs.h"
|
||||
|
||||
// NOTE: I guess this marker is used as a type discriminator for implementing
|
||||
// nested dictionaries. That's why every dictionary-related function starts
|
||||
// with a check for this value.
|
||||
#define DICTIONARY_MARKER 0xFEBAFEBA
|
||||
|
||||
// A tuple containing individual key-value pair of a dictionary.
|
||||
typedef struct DictionaryEntry {
|
||||
char* key;
|
||||
|
@ -42,17 +37,9 @@ typedef struct Dictionary {
|
|||
DictionaryEntry* entries;
|
||||
} Dictionary;
|
||||
|
||||
extern MallocProc* gDictionaryMallocProc;
|
||||
extern ReallocProc* gDictionaryReallocProc;
|
||||
extern FreeProc* gDictionaryFreeProc;
|
||||
|
||||
void* dictionaryMallocDefaultImpl(size_t size);
|
||||
void* dictionaryReallocDefaultImpl(void* ptr, size_t newSize);
|
||||
void dictionaryFreeDefaultImpl(void* ptr);
|
||||
int dictionaryInit(Dictionary* dictionary, int initialCapacity, size_t valueSize, void* a4);
|
||||
int dictionarySetCapacity(Dictionary* dictionary, int newCapacity);
|
||||
int dictionaryFree(Dictionary* dictionary);
|
||||
int dictionaryFindIndexForKey(Dictionary* dictionary, const char* key, int* index);
|
||||
int dictionaryGetIndexByKey(Dictionary* dictionary, const char* key);
|
||||
int dictionaryAddValue(Dictionary* dictionary, const char* key, const void* value);
|
||||
int dictionaryRemoveValue(Dictionary* dictionary, const char* key);
|
||||
|
|
Loading…
Reference in New Issue