|
Server 0.0.1
HTTP/REST server implementation
|
00001 00023 #include <search.h> 00024 00025 #include "session.h" 00026 #include "class.h" 00027 00028 00029 static 00030 inline 00031 int 00032 sessionAddComp(const void * _a, const void * _b) 00033 { 00034 Session a = (Session)_a; 00035 Session b = (Session)_b; 00036 return (a->id < b->id)? -1 : (a->id > b->id)? 1 : 0; 00037 } 00038 00039 Session 00040 sessionAdd(const Session * root, Session session) 00041 { 00042 Session * found = tsearch(session, (void**)root, sessionAddComp); 00043 00044 if (NULL == found) { 00045 return NULL; 00046 } 00047 00048 if (*found != session) { 00052 delete(session); 00053 } 00054 00055 return *found; 00056 } 00057 00058 // vim: set ts=4 sw=4: