examples/gkurve: ResizableLabel: fix deinit leaks
This issue with the previous (commented out) implementation was that by remaking the iterator each loop, the same element was attempted to be freed each iteration, as the element was not actually removed from the map.
This commit is contained in:
parent
8f6273c0d0
commit
35930b1600
1 changed files with 14 additions and 10 deletions
|
|
@ -31,6 +31,14 @@ const CharVertices = struct {
|
||||||
// But the other two points do, so put those in the indices
|
// But the other two points do, so put those in the indices
|
||||||
convex_vertices: VertexList,
|
convex_vertices: VertexList,
|
||||||
convex_vertices_indices: std.ArrayList(u16),
|
convex_vertices_indices: std.ArrayList(u16),
|
||||||
|
|
||||||
|
fn deinit(self: CharVertices) void {
|
||||||
|
self.filled_vertices.deinit();
|
||||||
|
self.filled_vertices_indices.deinit();
|
||||||
|
self.concave_vertices.deinit();
|
||||||
|
self.convex_vertices.deinit();
|
||||||
|
self.convex_vertices_indices.deinit();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
face: ft.Face,
|
face: ft.Face,
|
||||||
|
|
@ -77,16 +85,12 @@ pub fn init(self: *ResizableLabel, lib: ft.Library, font_path: []const u8, face_
|
||||||
pub fn deinit(label: *ResizableLabel) void {
|
pub fn deinit(label: *ResizableLabel) void {
|
||||||
label.face.deinit();
|
label.face.deinit();
|
||||||
label.tessellator.deinit();
|
label.tessellator.deinit();
|
||||||
// FIXME:
|
|
||||||
// std.debug.todo("valueIterator() doesn't stop? How do we deallocate the values?");
|
var iter = label.char_map.valueIterator();
|
||||||
// while (label.char_map.valueIterator().next()) |value| {
|
while (iter.next()) |ptr| {
|
||||||
// _ = value;
|
ptr.deinit();
|
||||||
// value.filled_vertices.deinit();
|
}
|
||||||
// value.filled_vertices_indices.deinit();
|
|
||||||
// value.convex_vertices.deinit();
|
|
||||||
// value.convex_vertices_indices.deinit();
|
|
||||||
// value.concave_vertices.deinit();
|
|
||||||
// }
|
|
||||||
label.char_map.deinit();
|
label.char_map.deinit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue