~jlukas79/+junk/mysql-server

« back to all changes in this revision

Viewing changes to mysys/safemalloc.c

manual merge 6.0-main --> 6.0-bka-review

Show diffs side-by-side

added added

removed removed

Lines of Context:
193
193
  if ((MyFlags & MY_ZEROFILL) || !sf_malloc_quick)
194
194
    bfill(data, size, (char) (MyFlags & MY_ZEROFILL ? 0 : ALLOC_VAL));
195
195
  /* Return a pointer to the real data */
196
 
  DBUG_PRINT("exit",("ptr: 0x%lx", (long) data));
 
196
  DBUG_PRINT("exit",("ptr: %p", data));
197
197
  if (sf_min_adress > data)
198
198
    sf_min_adress= data;
199
199
  if (sf_max_adress < data)
258
258
{
259
259
  struct st_irem *irem;
260
260
  DBUG_ENTER("_myfree");
261
 
  DBUG_PRINT("enter",("ptr: 0x%lx", (long) ptr));
 
261
  DBUG_PRINT("enter",("ptr: %p", ptr));
262
262
 
263
263
  if (!sf_malloc_quick)
264
264
    (void) _sanity (filename, lineno);
404
404
      if (file)
405
405
      {
406
406
        fprintf(file,
407
 
                "\t%6u bytes at 0x%09lx, allocated at line %4u in '%s'",
408
 
                irem->datasize, (long) data, irem->linenum, irem->filename);
 
407
                "\t%6lu bytes at 0x%09lx, allocated at line %4u in '%s'",
 
408
                (ulong) irem->datasize, (long) data,
 
409
                irem->linenum, irem->filename);
409
410
        fprintf(file, "\n");
410
411
        (void) fflush(file);
411
412
      }
412
413
      DBUG_PRINT("safe",
413
 
                 ("%6u bytes at 0x%09lx, allocated at line %4d in '%s'",
414
 
                  irem->datasize, (long) data, irem->linenum, irem->filename));
 
414
                 ("%6lu bytes at 0x%09lx, allocated at line %4d in '%s'",
 
415
                  (ulong) irem->datasize, (long) data,
 
416
                  irem->linenum, irem->filename));
415
417
      irem= irem->next;
416
418
    }
417
419
  }
430
432
}
431
433
 
432
434
 
 
435
/*
 
436
  Report where a piece of memory was allocated
 
437
 
 
438
  This is usefull to call from withing a debugger
 
439
*/
 
440
 
 
441
void sf_malloc_report_allocated(void *memory)
 
442
{
 
443
  struct st_irem *irem;  
 
444
  for (irem= sf_malloc_root ; irem ; irem=irem->next)
 
445
  {
 
446
    char *data= (((char*) irem) + ALIGN_SIZE(sizeof(struct st_irem)) +
 
447
                 sf_malloc_prehunc);
 
448
    if (data <= (char*) memory && (char*) memory <= data + irem->datasize)
 
449
    {
 
450
      printf("%lu bytes at 0x%lx, allocated at line %u in '%s'\n",
 
451
             (ulong) irem->datasize, (long) data,
 
452
             irem->linenum, irem->filename);
 
453
      break;
 
454
    }
 
455
  }
 
456
}
 
457
 
433
458
        /* Returns 0 if chunk is ok */
434
459
 
435
460
static int _checkchunk(register struct st_irem *irem, const char *filename,
447
472
            irem->filename, irem->linenum);
448
473
    fprintf(stderr, " discovered at %s:%d\n", filename, lineno);
449
474
    (void) fflush(stderr);
450
 
    DBUG_PRINT("safe",("Underrun at 0x%lx, allocated at %s:%d",
451
 
                       (long) data, irem->filename, irem->linenum));
 
475
    DBUG_PRINT("safe",("Underrun at %p, allocated at %s:%d",
 
476
                       data, irem->filename, irem->linenum));
452
477
    flag=1;
453
478
  }
454
479
 
463
488
            irem->filename, irem->linenum);
464
489
    fprintf(stderr, " discovered at '%s:%d'\n", filename, lineno);
465
490
    (void) fflush(stderr);
466
 
    DBUG_PRINT("safe",("Overrun at 0x%lx, allocated at %s:%d",
467
 
                       (long) data,
 
491
    DBUG_PRINT("safe",("Overrun at %p, allocated at %s:%d",
 
492
                       data,
468
493
                       irem->filename,
469
494
                       irem->linenum));
470
495
    flag=1;