Does the ordering of errdefer matter when cleaning up memory? For example, technically the struct variable should be freed before the struct that holds it. i.e. Does the order matter here? or can we assume that the memory is ok until we loose scope?
pub fn create(font: *Font, text: []const u8, box: Box, color: ray.Color, update_helper: TextUpdateFunc, allocator: std.mem.Allocator) !*TextElement {
var element = try allocator.create(TextElement);
errdefer allocator.destroy(element);
element.text = try allocator.dupeZ(u8, text);
errdefer allocator.free(element.text);
....
error happens