Changeset 40115
- Timestamp:
- Aug 9, 2017, 1:06:02 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ohana.20170809/src/libohana/src/ohana_allocate.c
r39457 r40115 47 47 } 48 48 49 int NdumpFile = 0; 50 49 51 void *ohana_malloc (const char *file, int line, const char *func, size_t Nelem, size_t esize) { 50 52 … … 53 55 size_t size; // total number of bytes requested (not items) 54 56 57 fprintf (stderr, "malloc: lastBlock: 0x%08lx, Nblock %d, Nelem: %zd, esize: %zd, (%s@%d : %s)\n", (long int) lastBlock, Nblock, Nelem, esize, file, line, func); 58 55 59 Nelem = MAX (1, Nelem); 56 60 size = Nelem * esize; 61 if (!size) abort(); 57 62 // if (size % 8) size += (8 - size % 8); // do NOT round to 8-byte boundary (did not fix corruption) 58 63 … … 78 83 new->Nalloc = 1; 79 84 85 if (!new->size) abort(); 86 80 87 // poison the whole memory: we should not rely of 0'ed memory 81 88 memset (ptr, 0x7f, new->size); … … 91 98 // lastBlock = m2 92 99 100 // if (!new->size) abort(); 101 93 102 // set up the pointers 94 103 new->nextBlock = NULL; 95 104 105 // if (!new->size) abort(); 106 96 107 // protect the list during this operation 97 108 pthread_mutex_lock(&memBlockListMutex); 98 109 110 if (!new->size) abort(); 111 99 112 if (lastBlock) { 100 113 lastBlock->nextBlock = new; … … 103 116 lastBlock = new; 104 117 118 if (!new->size) abort(); 119 105 120 Nblock ++; 106 121 pthread_mutex_unlock(&memBlockListMutex); 107 122 108 123 if (!new->nextBlock && !new->prevBlock && (Nblock > 1)) abort(); 124 125 if (!new->size) abort(); 126 127 if (0) { 128 char tmpname[1024]; 129 snprintf (tmpname, 1024, "dvopsps.memdump.%03d.txt", NdumpFile); 130 FILE *fdmp = fopen (tmpname, "w"); 131 ohana_memdump_file (fdmp, TRUE); 132 fclose (fdmp); 133 NdumpFile ++; 134 } 109 135 110 136 return (ptr); … … 116 142 OhanaMemblock *new; // new memblock associated with user memory 117 143 size_t size; 144 145 fprintf (stderr, "realloc: lastBlock: 0x%08lx, Nblock %d, Nelem: %zd, esize: %zd, (%s@%d : %s)\n", (long int) lastBlock, Nblock, Nelem, esize, file, line, func); 118 146 119 147 // just allocate if not previously allocated … … 229 257 OhanaMemblock *ref; 230 258 259 fprintf (stderr, "free: lastBlock: 0x%08lx, Nblock %d, freeBlock: 0x%08lx, (%s@%d : %s)\n", (long int) lastBlock, Nblock, (long int) in, file, line, func); 260 231 261 if (!in) return; 232 262 … … 454 484 if (Ntotal_drop || VERBOSE) { 455 485 fprintf (stderr, "%zd memory blocks dropped (%zd bytes total), %zd good, %zd bad", Ntotal_drop, Nbytes_drop, Ngood_drop, Nbad_drop); 456 fprintf (stderr, "@ %s:%d (% d)\n", myFile, myLine, myFunc);486 fprintf (stderr, "@ %s:%d (%s)\n", myFile, myLine, myFunc); 457 487 } 458 488 … … 513 543 if (Ntotal < 100) { 514 544 if (good) { 515 fprintf (f, " %zd %zd %zd GOOD %s %d, func: %s\n", Ntotal, thisBlock->size, Nbytes, thisBlock->file, thisBlock->line, thisBlock->func); 545 // fprintf (f, " %zd %zd %zd 0x%08lx, GOOD %s %d, func: %s\n", Ntotal, thisBlock->size, Nbytes, (long int) thisBlock, thisBlock->file, thisBlock->line, thisBlock->func); 546 fprintf (f, " %zd %zd %zd GOOD %s %d, func: %s\n", Ntotal, thisBlock->size, Nbytes, thisBlock->file, thisBlock->line, thisBlock->func); 516 547 } else { 517 fprintf (f, " %zd %zd %zd BAD %s %d, func: %s\n", Ntotal, thisBlock->size, Nbytes, thisBlock->file, thisBlock->line, thisBlock->func);548 fprintf (f, " %zd %zd %zd BAD %s %d, func: %s\n", Ntotal, thisBlock->size, Nbytes, thisBlock->file, thisBlock->line, thisBlock->func); 518 549 } 519 550 }
Note:
See TracChangeset
for help on using the changeset viewer.
