Mercurial > geeqie.yaz
diff src/filedata.c @ 874:fa39a4d786ad
Increase debugging info in file_data_ref() and file_data_unref().
When compiled with DEBUG defined, file and line of the caller is displayed
in debug log.
author | zas_ |
---|---|
date | Thu, 03 Jul 2008 08:33:10 +0000 |
parents | 0c3f6ef17d18 |
children | d8e1e820cee7 |
line wrap: on
line diff
--- a/src/filedata.c Wed Jul 02 08:38:47 2008 +0000 +++ b/src/filedata.c Thu Jul 03 08:33:10 2008 +0000 @@ -457,15 +457,25 @@ 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; } @@ -488,14 +498,26 @@ 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--; +#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; @@ -515,7 +537,7 @@ /* 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)