apprt: clean up how apprt initializes surfaces

This commit is contained in:
Mitchell Hashimoto
2023-05-31 21:08:50 -07:00
parent 0fca74c089
commit f31d6fb8fe
6 changed files with 50 additions and 33 deletions

View File

@@ -691,6 +691,21 @@ pub const Config = struct {
}
}
/// Create a shallow copy of this config. This will share all the memory
/// allocated with the previous config but will have a new arena for
/// any changes or new allocations. The config should have `deinit`
/// called when it is complete.
///
/// Beware: these shallow clones are not meant for a long lifetime,
/// they are just meant to exist temporarily for the duration of some
/// modifications. It is very important that the original config not
/// be deallocated while shallow clones exist.
pub fn shallowClone(self: *const Config, alloc_gpa: Allocator) Config {
var result = self.*;
result._arena = ArenaAllocator.init(alloc_gpa);
return result;
}
/// Create a copy of this configuration. This is useful as a starting
/// point for modifying a configuration since a config can NOT be
/// modified once it is in use by an app or surface.