mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-24 04:36:10 +03:00
Merge pull request #1673 from mitchellh/font-mem
font: SharedGridSet.Key needs to clone the DerivedConfig
This commit is contained in:
@ -367,7 +367,9 @@ pub const DerivedConfig = struct {
|
|||||||
@"adjust-strikethrough-position": ?Metrics.Modifier,
|
@"adjust-strikethrough-position": ?Metrics.Modifier,
|
||||||
@"adjust-strikethrough-thickness": ?Metrics.Modifier,
|
@"adjust-strikethrough-thickness": ?Metrics.Modifier,
|
||||||
|
|
||||||
pub fn init(alloc_gpa: Allocator, config: *const Config) !DerivedConfig {
|
/// Initialize a DerivedConfig. The config should be either a
|
||||||
|
/// config.Config or another DerivedConfig to clone from.
|
||||||
|
pub fn init(alloc_gpa: Allocator, config: anytype) !DerivedConfig {
|
||||||
var arena = ArenaAllocator.init(alloc_gpa);
|
var arena = ArenaAllocator.init(alloc_gpa);
|
||||||
errdefer arena.deinit();
|
errdefer arena.deinit();
|
||||||
const alloc = arena.allocator();
|
const alloc = arena.allocator();
|
||||||
@ -447,13 +449,20 @@ pub const Key = struct {
|
|||||||
|
|
||||||
pub fn init(
|
pub fn init(
|
||||||
alloc_gpa: Allocator,
|
alloc_gpa: Allocator,
|
||||||
config: *const DerivedConfig,
|
config_src: *const DerivedConfig,
|
||||||
font_size: DesiredSize,
|
font_size: DesiredSize,
|
||||||
) !Key {
|
) !Key {
|
||||||
var arena = ArenaAllocator.init(alloc_gpa);
|
var arena = ArenaAllocator.init(alloc_gpa);
|
||||||
errdefer arena.deinit();
|
errdefer arena.deinit();
|
||||||
const alloc = arena.allocator();
|
const alloc = arena.allocator();
|
||||||
|
|
||||||
|
// Clone our configuration. We need to do this because the lifetime
|
||||||
|
// of the derived config is usually shorter than that of a key
|
||||||
|
// and we use pointers into the derived config for the key. We
|
||||||
|
// can remove this if we wanted by dupe-ing the memory we use
|
||||||
|
// from DerivedConfig below.
|
||||||
|
var config = try DerivedConfig.init(alloc, config_src);
|
||||||
|
|
||||||
var descriptors = std.ArrayList(discovery.Descriptor).init(alloc);
|
var descriptors = std.ArrayList(discovery.Descriptor).init(alloc);
|
||||||
defer descriptors.deinit();
|
defer descriptors.deinit();
|
||||||
for (config.@"font-family".list.items) |family| {
|
for (config.@"font-family".list.items) |family| {
|
||||||
|
Reference in New Issue
Block a user