IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 40115


Ignore:
Timestamp:
Aug 9, 2017, 1:06:02 PM (9 years ago)
Author:
eugene
Message:

verbosity mods

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ohana.20170809/src/libohana/src/ohana_allocate.c

    r39457 r40115  
    4747}
    4848
     49int NdumpFile = 0;
     50
    4951void *ohana_malloc (const char *file, int line, const char *func, size_t Nelem, size_t esize) {
    5052
     
    5355  size_t size;                // total number of bytes requested (not items)
    5456
     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
    5559  Nelem = MAX (1, Nelem);
    5660  size = Nelem * esize;
     61  if (!size) abort();
    5762  // if (size % 8) size += (8 - size % 8); // do NOT round to 8-byte boundary (did not fix corruption)
    5863
     
    7883  new->Nalloc = 1;
    7984
     85  if (!new->size) abort();
     86
    8087  // poison the whole memory: we should not rely of 0'ed memory
    8188  memset (ptr, 0x7f, new->size);
     
    9198  // lastBlock = m2
    9299
     100//  if (!new->size) abort();
     101
    93102  // set up the pointers
    94103  new->nextBlock = NULL;
    95104
     105//  if (!new->size) abort();
     106
    96107  // protect the list during this operation
    97108  pthread_mutex_lock(&memBlockListMutex);
    98109
     110  if (!new->size) abort();
     111
    99112  if (lastBlock) {
    100113    lastBlock->nextBlock = new;
     
    103116  lastBlock = new;
    104117
     118  if (!new->size) abort();
     119
    105120  Nblock ++;
    106121  pthread_mutex_unlock(&memBlockListMutex);
    107122
    108123  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  }
    109135
    110136  return (ptr);
     
    116142  OhanaMemblock *new;         // new memblock associated with user memory
    117143  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);
    118146
    119147  // just allocate if not previously allocated
     
    229257  OhanaMemblock *ref;
    230258
     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
    231261  if (!in) return;
    232262
     
    454484  if (Ntotal_drop || VERBOSE) {
    455485    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);
    457487  }
    458488
     
    513543    if (Ntotal < 100) {
    514544      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);
    516547      } 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);
    518549      }
    519550    }
Note: See TracChangeset for help on using the changeset viewer.