Changeset 41154
- Timestamp:
- Nov 27, 2019, 5:29:35 AM (7 years ago)
- Location:
- trunk/Ohana/src/libohana
- Files:
-
- 4 edited
-
include/ohana_allocate.h (modified) (1 diff)
-
include/ohana_sort.h (modified) (1 diff)
-
src/ohana_allocate.c (modified) (4 diffs)
-
src/sorts.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/libohana/include/ohana_allocate.h
r39457 r41154 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) -
trunk/Ohana/src/libohana/include/ohana_sort.h
r40291 r41154 83 83 void isortfour (int *X, int *Y, int *Z, int *W, int N); 84 84 85 void dsort_indexonly (double *X, off_t *S, off_t N); 86 void dsort_int_indexonly (double *X, int *S, int N); 87 85 88 #endif -
trunk/Ohana/src/libohana/src/ohana_allocate.c
r40117 r41154 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 } -
trunk/Ohana/src/libohana/src/sorts.c
r40291 r41154 196 196 } 197 197 198 /* sort the index of a vector (vector stays unsorted) */ 199 void dsort_indexonly (double *X, off_t *S, off_t N) { 200 201 # define SWAPFUNC(A,B){ off_t itmp; \ 202 itmp = S[A]; S[A] = S[B]; S[B] = itmp; \ 203 } 204 # define COMPARE(A,B)((!isfinite(X[S[A]]) && isfinite(X[S[B]])) || (X[S[A]] < X[S[B]])) 205 206 OHANA_SORT (N, COMPARE, SWAPFUNC); 207 208 # undef SWAPFUNC 209 # undef COMPARE 210 211 } 212 213 /* sort the index of a vector (vector stays unsorted) */ 214 void dsort_int_indexonly (double *X, int *S, int N) { 215 216 # define SWAPFUNC(A,B){ int itmp; \ 217 itmp = S[A]; S[A] = S[B]; S[B] = itmp; \ 218 } 219 # define COMPARE(A,B)((!isfinite(X[S[A]]) && isfinite(X[S[B]])) || (X[S[A]] < X[S[B]])) 220 221 OHANA_SORT (N, COMPARE, SWAPFUNC); 222 223 # undef SWAPFUNC 224 # undef COMPARE 225 226 } 227 228
Note:
See TracChangeset
for help on using the changeset viewer.
