comparison 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
comparison
equal deleted inserted replaced
873:bd3bdceb1230 874:fa39a4d786ad
455 target->sidecar_files = filelist_sort(target->sidecar_files, SORT_NAME, TRUE); 455 target->sidecar_files = filelist_sort(target->sidecar_files, SORT_NAME, TRUE);
456 456
457 return target; 457 return target;
458 } 458 }
459 459
460 460 #ifdef DEBUG_FILEDATA
461 FileData *file_data_ref_debug(const gchar *file, gint line, FileData *fd)
462 #else
461 FileData *file_data_ref(FileData *fd) 463 FileData *file_data_ref(FileData *fd)
464 #endif
462 { 465 {
463 if (fd == NULL) return NULL; 466 if (fd == NULL) return NULL;
464 DEBUG_2("file_data_ref (%d): '%s'", fd->ref, fd->path); 467 #ifdef DEBUG_FILEDATA
465 468 if (fd->magick != 0x12345678)
466 // return g_memdup(fd, sizeof(FileData)); 469 DEBUG_0("fd magick mismatch at %s:%d", file, line);
470 #endif
467 g_assert(fd->magick == 0x12345678); 471 g_assert(fd->magick == 0x12345678);
468 fd->ref++; 472 fd->ref++;
473
474 #ifdef DEBUG_FILEDATA
475 DEBUG_2("file_data_ref (%d): '%s' @ %s:%d", fd->ref, fd->path, file, line);
476 #else
477 DEBUG_2("file_data_ref (%d): '%s'", fd->ref, fd->path);
478 #endif
469 return fd; 479 return fd;
470 } 480 }
471 481
472 static void file_data_free(FileData *fd) 482 static void file_data_free(FileData *fd)
473 { 483 {
486 496
487 file_data_change_info_free(NULL, fd); 497 file_data_change_info_free(NULL, fd);
488 g_free(fd); 498 g_free(fd);
489 } 499 }
490 500
501 #ifdef DEBUG_FILEDATA
502 void file_data_unref_debug(const gchar *file, gint line, FileData *fd)
503 #else
491 void file_data_unref(FileData *fd) 504 void file_data_unref(FileData *fd)
505 #endif
492 { 506 {
493 if (fd == NULL) return; 507 if (fd == NULL) return;
508 #ifdef DEBUG_FILEDATA
509 if (fd->magick != 0x12345678)
510 DEBUG_0("fd magick mismatch @ %s:%d", file, line);
511 #endif
494 g_assert(fd->magick == 0x12345678); 512 g_assert(fd->magick == 0x12345678);
495 513
496 fd->ref--; 514 fd->ref--;
515 #ifdef DEBUG_FILEDATA
516 DEBUG_2("file_data_unref (%d): '%s' @ %s:%d", fd->ref, fd->path, file, line);
517
518 #else
497 DEBUG_2("file_data_unref (%d): '%s'", fd->ref, fd->path); 519 DEBUG_2("file_data_unref (%d): '%s'", fd->ref, fd->path);
498 520 #endif
499 if (fd->ref == 0) 521 if (fd->ref == 0)
500 { 522 {
501 GList *work; 523 GList *work;
502 FileData *parent = fd->parent ? fd->parent : fd; 524 FileData *parent = fd->parent ? fd->parent : fd;
503 525
513 work = work->next; 535 work = work->next;
514 } 536 }
515 537
516 /* none of parent/children is referenced, we can free everything */ 538 /* none of parent/children is referenced, we can free everything */
517 539
518 DEBUG_2("file_data_unref: deleting '%s', parent '%s'", fd->path, parent->path); 540 DEBUG_2("file_data_unref: deleting '%s', parent '%s'", fd->path, fd->parent ? parent->path : "-");
519 541
520 work = parent->sidecar_files; 542 work = parent->sidecar_files;
521 while (work) 543 while (work)
522 { 544 {
523 FileData *sfd = work->data; 545 FileData *sfd = work->data;