taskrambler  v0.1.8
Web server and task management solution.
add.c File Reference
#include <search.h>
#include "hash.h"
#include "class.h"
+ Include dependency graph for add.c:

Go to the source code of this file.

Functions

static int hashAddComp (const void *a, const void *b)
 
void * hashAdd (Hash this, void *operand)
 

Detailed Description

Author
Georg Hopp

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file add.c.

Function Documentation

void* hashAdd ( Hash  this,
void *  operand 
)

Definition at line 48 of file add.c.

References hashableHandleDouble(), hashAddComp(), and treeInsert().

Referenced by applicationSessionGet(), applicationSessionStart(), assetPoolGet(), configCtor(), httpParserHeader(), httpParserPostVars(), httpParserRequestVars(), httpResponse304(), httpResponse404(), httpResponse500(), httpResponseAsset(), httpResponseJson(), httpWorkerAddCommonHeader(), httpWorkerAddComputedHeader(), main(), and readMimeTypes().

49 {
50  void * found = treeInsert(&this->root, operand, hashAddComp);
51 
52  if (NULL == found) {
53  return NULL;
54  }
55 
56  if (operand != found) {
57  hashableHandleDouble(found, operand);
58  delete(operand);
59  }
60 
61  return found;
62 }
static int hashAddComp(const void *a, const void *b)
Definition: add.c:31
void * treeInsert(Tree *, const void *, TreeComp)
Definition: insert.c:29
void hashableHandleDouble(void *, void *)
Definition: hashable.c:62

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int hashAddComp ( const void *  a,
const void *  b 
)
inlinestatic

Definition at line 31 of file add.c.

References hashableGetHash().

Referenced by hashAdd().

32 {
33  unsigned long hash_a = hashableGetHash((void*)a);
34  unsigned long hash_b = hashableGetHash((void*)b);
35 
36  if (hash_a < hash_b) {
37  return -1;
38  }
39 
40  if (hash_a > hash_b) {
41  return 1;
42  }
43 
44  return 0;
45 }
unsigned long hashableGetHash(void *)
Definition: hashable.c:36

+ Here is the call graph for this function:

+ Here is the caller graph for this function: