MCPcopy Create free account
hub / github.com/TurningWheel/Barony / ttfTextHashStore

Function ttfTextHashStore

src/hash.cpp:56–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54}
55
56SDL_Surface* ttfTextHashStore(list_t* buckets, char* str, TTF_Font* font, bool outline, SDL_Surface* surf)
57{
58 ttfTextHash_t* hashedVal;
59 node_t* node;
60
61 // retrieve bucket
62 list_t* list = &buckets[djb2Hash(str) % HASH_SIZE];
63
64 // add surface to bucket
65 if ( (node = list_AddNodeFirst(list)) == NULL )
66 {
67 return NULL;
68 }
69 else
70 {
71 hashedVal = (ttfTextHash_t*) malloc(sizeof(ttfTextHash_t));
72 hashedVal->str = (char*) calloc(strlen(str) + 1, sizeof(char));
73 strcpy(hashedVal->str, str);
74 hashedVal->surf = surf;
75 hashedVal->font = font;
76 hashedVal->outline = outline;
77
78 node->deconstructor = &ttfTextHash_deconstructor;
79 node->size = sizeof(ttfTextHash_t);
80 node->element = hashedVal;
81
82 return surf;
83 }
84}

Callers

nothing calls this directly

Calls 2

djb2HashFunction · 0.85
list_AddNodeFirstFunction · 0.85

Tested by

no test coverage detected