File tree 3 files changed +11
-0
lines changed
3 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ pub const Json = struct {
21
21
22
22
pub fn init (allocator : Allocator , config : Config ) ! Json {
23
23
const buf = try allocator .alloc (u8 , config .max_size );
24
+ errdefer allocator .free (buf );
24
25
25
26
var prefix_length : usize = 0 ;
26
27
if (config .prefix ) | prefix | {
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ pub const LogFmt = struct {
20
20
21
21
pub fn init (allocator : Allocator , config : Config ) ! LogFmt {
22
22
const buf = try allocator .alloc (u8 , config .max_size );
23
+ errdefer allocator .free (buf );
23
24
24
25
var prefix_length : usize = 0 ;
25
26
if (config .prefix ) | prefix | {
Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ pub const Pool = struct {
25
25
26
26
const pool = try allocator .create (Pool );
27
27
errdefer allocator .destroy (pool );
28
+
28
29
pool .* = .{
29
30
.mutex = .{},
30
31
.config = config ,
@@ -34,8 +35,16 @@ pub const Pool = struct {
34
35
.level = @intFromEnum (config .level ),
35
36
};
36
37
38
+ var initialized : usize = 0 ;
39
+ errdefer {
40
+ for (0.. initialized ) | i | {
41
+ pool .destroyLogger (loggers [i ]);
42
+ }
43
+ }
44
+
37
45
for (0.. size ) | i | {
38
46
loggers [i ] = try pool .createLogger ();
47
+ initialized += 1 ;
39
48
}
40
49
41
50
return pool ;
You can’t perform that action at this time.
0 commit comments