Skip to content

Commit 910261d

Browse files
committed
Free GDateTime object in fileinfo methods
1 parent afc4684 commit 910261d

File tree

2 files changed

+9
-16
lines changed

2 files changed

+9
-16
lines changed

lib/backend/fs.dart

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,6 @@ import 'package:ffi/ffi.dart';
77
import 'package:files/backend/fs_native.dart';
88
import 'package:flutter/foundation.dart';
99

10-
// !copy: progress, cancellable, error (source, dest)
11-
// !create: cancellable, error (source)
12-
// !delete: cancellable, error (source)
13-
// !enumerate: cancellable, error (source)
14-
// make_directory: cancellable, error (source)
15-
// !move: progress, cancellable, error (source, dest)
16-
// !query_info: cancellable, error (source)
17-
// !trash: cancellable, error (source)
18-
1910
void initFileSystemThread() {
2011
// TODO: handle pointer management
2112
init_io_thread();

src/src/lib.zig

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
const _file = @import("file");
2-
const _file_enum = @import("file_enum");
3-
const _misc = @import("misc");
4-
51
const std = @import("std");
62
const c = @cImport({
73
@cInclude("glib.h");
@@ -393,23 +389,29 @@ pub export fn fileinfo_get_file_type(info: *c.GFileInfo) c_uint {
393389
pub export fn fileinfo_get_creation_time(info: *c.GFileInfo) ?[*]const u8 {
394390
const time = c.g_file_info_get_creation_date_time(info);
395391
if (time) |_time| {
396-
return c.g_date_time_format_iso8601(_time);
392+
const iso_str = c.g_date_time_format_iso8601(_time);
393+
c.g_date_time_unref(time);
394+
return iso_str;
397395
}
398396
return null;
399397
}
400398

401399
pub export fn fileinfo_get_access_time(info: *c.GFileInfo) ?[*]const u8 {
402400
const time = c.g_file_info_get_access_date_time(info);
403401
if (time) |_time| {
404-
return c.g_date_time_format_iso8601(_time);
402+
const iso_str = c.g_date_time_format_iso8601(_time);
403+
c.g_date_time_unref(time);
404+
return iso_str;
405405
}
406406
return null;
407407
}
408408

409409
pub export fn fileinfo_get_modification_time(info: *c.GFileInfo) ?[*]const u8 {
410410
const time = c.g_file_info_get_modification_date_time(info);
411411
if (time) |_time| {
412-
return c.g_date_time_format_iso8601(_time);
412+
const iso_str = c.g_date_time_format_iso8601(_time);
413+
c.g_date_time_unref(time);
414+
return iso_str;
413415
}
414416
return null;
415417
}

0 commit comments

Comments
 (0)