Server 0.0.1
HTTP/REST server implementation

src/hash/add.c

Go to the documentation of this file.
00001 
00023 #include <search.h>
00024 
00025 #include "hash.h"
00026 #include "class.h"
00027 
00028 static
00029 inline
00030 int
00031 hashAddComp(const void * a, const void * b)
00032 {
00033         return hashableGetHash((void*)b) - hashableGetHash((void*)a);
00034 }
00035 
00036 void *
00037 hashAdd(Hash this, void * operand)
00038 {
00039         void * found = tsearch(operand, &(this->root), hashAddComp);
00040 
00041         if (NULL == found) {
00042                 return NULL;
00043         }
00044 
00045         if (operand != *(void**)found) {
00046                 hashableHandleDouble(*(void**)found, operand);
00047                 delete(operand);
00048         }
00049 
00050         return *(void**)found;
00051 }
00052 
00053 // vim: set ts=4 sw=4:
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines