~bkerensa/ubuntu/raring/valgrind/merge-from-deb

« back to all changes in this revision

Viewing changes to coregrind/m_replacemalloc/vg_replace_malloc.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastian Dröge
  • Date: 2006-11-16 17:56:30 UTC
  • mfrom: (1.2.2 upstream)
  • mto: This revision was merged to the branch mainline in revision 14.
  • Revision ID: james.westby@ubuntu.com-20061116175630-hatkgajb0twz0upw
Tags: upstream-3.2.1
Import upstream version 3.2.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
358
358
MALLOPT(m_libc_dot_so_star, mallopt);
359
359
 
360
360
 
 
361
// Documentation says:
 
362
//   malloc_trim(size_t pad);
 
363
// 
 
364
//   If possible, gives memory back to the system (via negative arguments to
 
365
//   sbrk) if there is unused memory at the `high' end of the malloc pool.
 
366
//   You can call this after freeing large blocks of memory to potentially
 
367
//   reduce the system-level memory requirements of a program. However, it
 
368
//   cannot guarantee to reduce memory.  Under some allocation patterns,
 
369
//   some large free blocks of memory will be locked between two used
 
370
//   chunks, so they cannot be given back to the system.
 
371
// 
 
372
//   The `pad' argument to malloc_trim represents the amount of free
 
373
//   trailing space to leave untrimmed. If this argument is zero, only the
 
374
//   minimum amount of memory to maintain internal data structures will be
 
375
//   left (one page or less). Non-zero arguments can be supplied to maintain
 
376
//   enough trailing space to service future expected allocations without
 
377
//   having to re-obtain memory from the system.
 
378
// 
 
379
//   Malloc_trim returns 1 if it actually released any memory, else 0. On
 
380
//   systems that do not support "negative sbrks", it will always return 0. 
 
381
//
 
382
// For simplicity, we always return 0.
 
383
#define MALLOC_TRIM(soname, fnname) \
 
384
   \
 
385
   int VG_REPLACE_FUNCTION_ZU(soname, fnname) ( SizeT pad ); \
 
386
   int VG_REPLACE_FUNCTION_ZU(soname, fnname) ( SizeT pad )  \
 
387
   { \
 
388
      /* 0 denotes that malloc_trim() either wasn't able \
 
389
         to do anything, or was not implemented */ \
 
390
      return 0; \
 
391
   }
 
392
 
 
393
MALLOC_TRIM(m_libc_dot_so_star, malloc_trim);
 
394
 
 
395
 
361
396
#define POSIX_MEMALIGN(soname, fnname) \
362
397
   \
363
398
   int VG_REPLACE_FUNCTION_ZU(soname, fnname) ( void **memptr, \
427
462
 
428
463
PANIC(m_libc_dot_so_star, pvalloc);
429
464
PANIC(m_libc_dot_so_star, malloc_stats);
430
 
PANIC(m_libc_dot_so_star, malloc_trim);
431
465
PANIC(m_libc_dot_so_star, malloc_get_state);
432
466
PANIC(m_libc_dot_so_star, malloc_set_state);
433
467