mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 07:11:41 +00:00
[ui] Fix more memory leaks
The text passage component was a legitimate leak, but the rest just shutdown losses (ie, valgrind noise).
This commit is contained in:
parent
e81c3a6015
commit
004ebd40b8
3 changed files with 37 additions and 0 deletions
|
@ -59,12 +59,19 @@ copy_glyph (vrect_t *rect, FT_GlyphSlot src_glyph, font_t *font)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
Font_shutdown (void *data)
|
||||
{
|
||||
FT_Done_FreeType (ft);
|
||||
}
|
||||
|
||||
VISIBLE void
|
||||
Font_Init (void)
|
||||
{
|
||||
if (FT_Init_FreeType (&ft)) {
|
||||
Sys_Error ("Could not init FreeType library");
|
||||
}
|
||||
Sys_RegisterShutdown (Font_shutdown, 0);
|
||||
}
|
||||
|
||||
VISIBLE void
|
||||
|
|
|
@ -43,6 +43,13 @@
|
|||
|
||||
#include "compat.h"
|
||||
|
||||
static void
|
||||
text_passage_glyphs_destroy (void *_glyphset)
|
||||
{
|
||||
glyphset_t *glyphset = _glyphset;
|
||||
free (glyphset->glyphs);
|
||||
}
|
||||
|
||||
static void
|
||||
text_features_create (void *_features)
|
||||
{
|
||||
|
@ -61,6 +68,7 @@ const component_t text_components[text_comp_count] = {
|
|||
[text_passage_glyphs] = {
|
||||
.size = sizeof (glyphset_t),
|
||||
.name = "passage glyphs",
|
||||
.destroy = text_passage_glyphs_destroy,
|
||||
},
|
||||
[text_glyphs] = {
|
||||
.size = sizeof (glyphref_t),
|
||||
|
@ -282,6 +290,8 @@ Text_View (ecs_system_t viewsys, font_t *font, passage_t *passage)
|
|||
.count = glyph_count,
|
||||
};
|
||||
Ent_SetComponent (passage_view.id, text_passage_glyphs, reg, &glyphset);
|
||||
hb_buffer_destroy (buffer);
|
||||
hb_font_destroy (fnt);
|
||||
return passage_view;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "QF/darray.h"
|
||||
#include "QF/mathlib.h"
|
||||
|
||||
#include "QF/ui/vrect.h"
|
||||
|
@ -42,6 +43,7 @@
|
|||
#define RECT_BLOCK 128
|
||||
#ifndef TEST_MEMORY
|
||||
static vrect_t *free_rects;
|
||||
static struct DARRAY_TYPE(vrect_t *) rect_sets = DARRAY_STATIC_INIT (32);
|
||||
#endif
|
||||
|
||||
VISIBLE vrect_t *
|
||||
|
@ -56,6 +58,7 @@ VRect_New (int x, int y, int width, int height)
|
|||
for (i = 0; i < RECT_BLOCK - 1; i++)
|
||||
free_rects[i].next = &free_rects[i + 1];
|
||||
free_rects[i].next = 0;
|
||||
DARRAY_APPEND (&rect_sets, free_rects);
|
||||
}
|
||||
r = free_rects;
|
||||
free_rects = free_rects->next;
|
||||
|
@ -319,3 +322,20 @@ VRect_SubRect (const vrect_t *rect, int width, int height)
|
|||
VRect_Delete (r);
|
||||
return s;
|
||||
}
|
||||
|
||||
#ifndef TEST_MEMORY
|
||||
static void
|
||||
vrect_shutdown (void *data)
|
||||
{
|
||||
for (size_t i = 0; i < rect_sets.size; i++) {
|
||||
free (rect_sets.a[i]);
|
||||
}
|
||||
DARRAY_CLEAR (&rect_sets);
|
||||
}
|
||||
|
||||
static void __attribute__((constructor))
|
||||
vrect_init (void)
|
||||
{
|
||||
Sys_RegisterShutdown (vrect_shutdown, 0);
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue