return target;
}
-
+#ifdef DEBUG_FILEDATA
+FileData *file_data_ref_debug(const gchar *file, gint line, FileData *fd)
+#else
FileData *file_data_ref(FileData *fd)
+#endif
{
if (fd == NULL) return NULL;
- DEBUG_2("file_data_ref (%d): '%s'", fd->ref, fd->path);
-
-// return g_memdup(fd, sizeof(FileData));
+#ifdef DEBUG_FILEDATA
+ if (fd->magick != 0x12345678)
+ DEBUG_0("fd magick mismatch at %s:%d", file, line);
+#endif
g_assert(fd->magick == 0x12345678);
fd->ref++;
+
+#ifdef DEBUG_FILEDATA
+ DEBUG_2("file_data_ref (%d): '%s' @ %s:%d", fd->ref, fd->path, file, line);
+#else
+ DEBUG_2("file_data_ref (%d): '%s'", fd->ref, fd->path);
+#endif
return fd;
}
g_free(fd);
}
+#ifdef DEBUG_FILEDATA
+void file_data_unref_debug(const gchar *file, gint line, FileData *fd)
+#else
void file_data_unref(FileData *fd)
+#endif
{
if (fd == NULL) return;
+#ifdef DEBUG_FILEDATA
+ if (fd->magick != 0x12345678)
+ DEBUG_0("fd magick mismatch @ %s:%d", file, line);
+#endif
g_assert(fd->magick == 0x12345678);
-
+
fd->ref--;
- DEBUG_2("file_data_unref (%d): '%s'", fd->ref, fd->path);
+#ifdef DEBUG_FILEDATA
+ DEBUG_2("file_data_unref (%d): '%s' @ %s:%d", fd->ref, fd->path, file, line);
+#else
+ DEBUG_2("file_data_unref (%d): '%s'", fd->ref, fd->path);
+#endif
if (fd->ref == 0)
{
GList *work;
/* none of parent/children is referenced, we can free everything */
- DEBUG_2("file_data_unref: deleting '%s', parent '%s'", fd->path, parent->path);
+ DEBUG_2("file_data_unref: deleting '%s', parent '%s'", fd->path, fd->parent ? parent->path : "-");
work = parent->sidecar_files;
while (work)
#ifndef FILEDATA_H
#define FILEDATA_H
+#ifdef DEBUG
+#define DEBUG_FILEDATA
+#endif
+
gchar *text_from_size(gint64 size);
gchar *text_from_size_abrev(gint64 size);
const gchar *text_from_time(time_t t);
/* this expects a utf-8 path */
FileData *file_data_new_simple(const gchar *path_utf8);
+#ifdef DEBUG_FILEDATA
+FileData *file_data_ref_debug(const gchar *file, gint line, FileData *fd);
+void file_data_unref_debug(const gchar *file, gint line, FileData *fd);
+#define file_data_ref(fd) file_data_ref_debug(__FILE__, __LINE__, fd)
+#define file_data_unref(fd) file_data_unref_debug(__FILE__, __LINE__, fd)
+#else
FileData *file_data_ref(FileData *fd);
void file_data_unref(FileData *fd);
+#endif
void file_data_increment_version(FileData *fd);