Changeset 40774
- Timestamp:
- Jun 2, 2019, 5:33:14 PM (7 years ago)
- Location:
- branches/eam_branches/ohana.20190329/src/libohana
- Files:
-
- 2 edited
-
include/ohana_allocate.h (modified) (1 diff)
-
src/ohana_allocate.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ohana.20190329/src/libohana/include/ohana_allocate.h
r39457 r40774 44 44 void ohana_memcheck_block_func (const char *myFile, int myLine, const char *myFunc, void *in); 45 45 void real_free (void *in); 46 47 void ohana_memdump_strings_file (FILE *f, int VERBOSE); 48 void ohana_memdump_set_maxlines (int N); 46 49 47 50 # define ohana_memcheck(X) ohana_memcheck_func (__FILE__, __LINE__, __func__, X) -
branches/eam_branches/ohana.20190329/src/libohana/src/ohana_allocate.c
r40117 r40774 45 45 46 46 static pthread_mutex_t memBlockListMutex = PTHREAD_MUTEX_INITIALIZER; 47 48 static int NblockMaxDump = 100; 47 49 48 50 void ohana_meminit () { … … 435 437 fprintf (stderr, "memory corruption\n"); 436 438 } 437 if (Nbad < 100) {439 if (Nbad < NblockMaxDump) { 438 440 fprintf (stderr, " file: %s, line: %d, func: %s\n", thisBlock->file, thisBlock->line, thisBlock->func); 439 441 } … … 613 615 Nbytes += thisBlock->size; 614 616 615 if (Ntotal < 100) {617 if (Ntotal < NblockMaxDump) { 616 618 if (good) { 617 619 fprintf (f, " %zd %zd %zd GOOD %s %d, func: %s\n", Ntotal, thisBlock->size, Nbytes, thisBlock->file, thisBlock->line, thisBlock->func); … … 677 679 return memstats; 678 680 } 681 682 void ohana_memdump_strings_file (FILE *f, int VERBOSE) { 683 684 if (!lastBlock) { 685 if (VERBOSE) fprintf (f, "no memory allocated\n"); 686 return; 687 } 688 689 OhanaMemblock *thisBlock = lastBlock; 690 691 size_t Ntotal = 0; 692 size_t Nbytes = 0; 693 size_t Nstring = 0; 694 695 fprintf (f, " entry | bytes | cumulative : line : string\n"); 696 697 while (thisBlock) { 698 699 // pointer to the start of the user memory 700 char *ptr = (char *)(thisBlock + 1); 701 702 Ntotal ++; 703 Nbytes += thisBlock->size; 704 705 int N = strlen(thisBlock->file); 706 if (N > 22) { 707 int found = !strcmp("libohana/src/string.c", &thisBlock->file[N - 21]); 708 if (found) { 709 if (Nstring < NblockMaxDump) { 710 fprintf (f, " %8zd | %8zd | %10zd : %4d : %s\n", Ntotal, thisBlock->size, Nbytes, thisBlock->line, ptr); 711 } 712 Nstring ++; 713 } 714 thisBlock = thisBlock->prevBlock; 715 } 716 } 717 718 if (Nstring || VERBOSE) { 719 fprintf (f, "%zd strings allocated\n", Nstring); 720 } 721 722 return; 723 } 724 725 void ohana_memdump_set_maxlines (int N) { 726 NblockMaxDump = N; 727 }
Note:
See TracChangeset
for help on using the changeset viewer.
