Skip to content

Commit

Permalink
Updated hash table implementation to match SDL
Browse files Browse the repository at this point in the history
Also redefine hash table functions so they don't collide with SDL when statically linking.

Fixes #508
  • Loading branch information
slouken committed Feb 17, 2025
1 parent 94dbe5b commit d611cd4
Show file tree
Hide file tree
Showing 8 changed files with 852 additions and 305 deletions.
8 changes: 4 additions & 4 deletions src/SDL_gpu_textengine.c
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,7 @@ static TTF_GPUTextEngineFontData *CreateFontData(TTF_GPUTextEngineData *engineda
return NULL;
}

if (!SDL_InsertIntoHashTable(enginedata->fonts, font, data)) {
if (!SDL_InsertIntoHashTable(enginedata->fonts, font, data, true)) {
DestroyFontData(data);
return NULL;
}
Expand All @@ -872,7 +872,7 @@ static void DestroyEngineData(TTF_GPUTextEngineData *data)
SDL_free(data);
}

static void NukeFontData(const void *key, const void *value, void *unused)
static void SDLCALL NukeFontData(void *unused, const void *key, const void *value)
{
TTF_GPUTextEngineFontData *data = (TTF_GPUTextEngineFontData *)value;
(void)key;
Expand All @@ -890,7 +890,7 @@ static TTF_GPUTextEngineData *CreateEngineData(SDL_GPUDevice *device, int atlas_
data->atlas_texture_size = atlas_texture_size;
data->winding = TTF_GPU_TEXTENGINE_WINDING_CLOCKWISE;

data->fonts = SDL_CreateHashTable(NULL, 4, SDL_HashPointer, SDL_KeyMatchPointer, NukeFontData, false, false);
data->fonts = SDL_CreateHashTable(0, false, SDL_HashPointer, SDL_KeyMatchPointer, NukeFontData, NULL);
if (!data->fonts) {
DestroyEngineData(data);
return NULL;
Expand All @@ -914,7 +914,7 @@ static bool SDLCALL CreateText(void *userdata, TTF_Text *text)
return false;
}
} else if (font_generation != fontdata->generation) {
SDL_EmptyHashTable(fontdata->glyphs);
SDL_ClearHashTable(fontdata->glyphs);
fontdata->generation = font_generation;
}

Expand Down
Loading

0 comments on commit d611cd4

Please sign in to comment.