Blame malloc/malloc.h

Packit 6c4009
/* Prototypes and definition for malloc implementation.
Packit 6c4009
   Copyright (C) 1996-2018 Free Software Foundation, Inc.
Packit 6c4009
   This file is part of the GNU C Library.
Packit 6c4009
Packit 6c4009
   The GNU C Library is free software; you can redistribute it and/or
Packit 6c4009
   modify it under the terms of the GNU Lesser General Public
Packit 6c4009
   License as published by the Free Software Foundation; either
Packit 6c4009
   version 2.1 of the License, or (at your option) any later version.
Packit 6c4009
Packit 6c4009
   The GNU C Library is distributed in the hope that it will be useful,
Packit 6c4009
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6c4009
   Lesser General Public License for more details.
Packit 6c4009
Packit 6c4009
   You should have received a copy of the GNU Lesser General Public
Packit 6c4009
   License along with the GNU C Library; if not, see
Packit 6c4009
   <http://www.gnu.org/licenses/>.  */
Packit 6c4009
Packit 6c4009
#ifndef _MALLOC_H
Packit 6c4009
#define _MALLOC_H 1
Packit 6c4009
Packit 6c4009
#include <features.h>
Packit 6c4009
#include <stddef.h>
Packit 6c4009
#include <stdio.h>
Packit 6c4009
Packit 6c4009
#ifdef _LIBC
Packit 6c4009
# define __MALLOC_HOOK_VOLATILE
Packit 6c4009
# define __MALLOC_DEPRECATED
Packit 6c4009
#else
Packit 6c4009
# define __MALLOC_HOOK_VOLATILE volatile
Packit 6c4009
# define __MALLOC_DEPRECATED __attribute_deprecated__
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
Packit 6c4009
__BEGIN_DECLS
Packit 6c4009
Packit 6c4009
/* Allocate SIZE bytes of memory.  */
Packit 6c4009
extern void *malloc (size_t __size) __THROW __attribute_malloc__ __wur;
Packit 6c4009
Packit 6c4009
/* Allocate NMEMB elements of SIZE bytes each, all initialized to 0.  */
Packit 6c4009
extern void *calloc (size_t __nmemb, size_t __size)
Packit 6c4009
__THROW __attribute_malloc__ __wur;
Packit 6c4009
Packit 6c4009
/* Re-allocate the previously allocated block in __ptr, making the new
Packit 6c4009
   block SIZE bytes long.  */
Packit 6c4009
/* __attribute_malloc__ is not used, because if realloc returns
Packit 6c4009
   the same pointer that was passed to it, aliasing needs to be allowed
Packit 6c4009
   between objects pointed by the old and new pointers.  */
Packit 6c4009
extern void *realloc (void *__ptr, size_t __size)
Packit 6c4009
__THROW __attribute_warn_unused_result__;
Packit 6c4009
Packit 6c4009
/* Re-allocate the previously allocated block in PTR, making the new
Packit 6c4009
   block large enough for NMEMB elements of SIZE bytes each.  */
Packit 6c4009
/* __attribute_malloc__ is not used, because if reallocarray returns
Packit 6c4009
   the same pointer that was passed to it, aliasing needs to be allowed
Packit 6c4009
   between objects pointed by the old and new pointers.  */
Packit 6c4009
extern void *reallocarray (void *__ptr, size_t __nmemb, size_t __size)
Packit 6c4009
__THROW __attribute_warn_unused_result__;
Packit 6c4009
Packit 6c4009
/* Free a block allocated by `malloc', `realloc' or `calloc'.  */
Packit 6c4009
extern void free (void *__ptr) __THROW;
Packit 6c4009
Packit 6c4009
/* Allocate SIZE bytes allocated to ALIGNMENT bytes.  */
Packit 6c4009
extern void *memalign (size_t __alignment, size_t __size)
Packit 6c4009
__THROW __attribute_malloc__ __wur;
Packit 6c4009
Packit 6c4009
/* Allocate SIZE bytes on a page boundary.  */
Packit 6c4009
extern void *valloc (size_t __size) __THROW __attribute_malloc__ __wur;
Packit 6c4009
Packit 6c4009
/* Equivalent to valloc(minimum-page-that-holds(n)), that is, round up
Packit 6c4009
   __size to nearest pagesize. */
Packit 6c4009
extern void *pvalloc (size_t __size) __THROW __attribute_malloc__ __wur;
Packit 6c4009
Packit 6c4009
/* Underlying allocation function; successive calls should return
Packit 6c4009
   contiguous pieces of memory.  */
Packit 6c4009
extern void *(*__morecore) (ptrdiff_t __size);
Packit 6c4009
Packit 6c4009
/* Default value of `__morecore'.  */
Packit 6c4009
extern void *__default_morecore (ptrdiff_t __size)
Packit 6c4009
__THROW __attribute_malloc__;
Packit 6c4009
Packit 6c4009
/* SVID2/XPG mallinfo structure */
Packit 6c4009
Packit 6c4009
struct mallinfo
Packit 6c4009
{
Packit 6c4009
  int arena;    /* non-mmapped space allocated from system */
Packit 6c4009
  int ordblks;  /* number of free chunks */
Packit 6c4009
  int smblks;   /* number of fastbin blocks */
Packit 6c4009
  int hblks;    /* number of mmapped regions */
Packit 6c4009
  int hblkhd;   /* space in mmapped regions */
Packit 6c4009
  int usmblks;  /* always 0, preserved for backwards compatibility */
Packit 6c4009
  int fsmblks;  /* space available in freed fastbin blocks */
Packit 6c4009
  int uordblks; /* total allocated space */
Packit 6c4009
  int fordblks; /* total free space */
Packit 6c4009
  int keepcost; /* top-most, releasable (via malloc_trim) space */
Packit 6c4009
};
Packit 6c4009
Packit 6c4009
/* Returns a copy of the updated current mallinfo. */
Packit 6c4009
extern struct mallinfo mallinfo (void) __THROW;
Packit 6c4009
Packit 6c4009
/* SVID2/XPG mallopt options */
Packit 6c4009
#ifndef M_MXFAST
Packit 6c4009
# define M_MXFAST  1    /* maximum request size for "fastbins" */
Packit 6c4009
#endif
Packit 6c4009
#ifndef M_NLBLKS
Packit 6c4009
# define M_NLBLKS  2    /* UNUSED in this malloc */
Packit 6c4009
#endif
Packit 6c4009
#ifndef M_GRAIN
Packit 6c4009
# define M_GRAIN   3    /* UNUSED in this malloc */
Packit 6c4009
#endif
Packit 6c4009
#ifndef M_KEEP
Packit 6c4009
# define M_KEEP    4    /* UNUSED in this malloc */
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
/* mallopt options that actually do something */
Packit 6c4009
#define M_TRIM_THRESHOLD    -1
Packit 6c4009
#define M_TOP_PAD           -2
Packit 6c4009
#define M_MMAP_THRESHOLD    -3
Packit 6c4009
#define M_MMAP_MAX          -4
Packit 6c4009
#define M_CHECK_ACTION      -5
Packit 6c4009
#define M_PERTURB           -6
Packit 6c4009
#define M_ARENA_TEST        -7
Packit 6c4009
#define M_ARENA_MAX         -8
Packit 6c4009
Packit 6c4009
/* General SVID/XPG interface to tunable parameters. */
Packit 6c4009
extern int mallopt (int __param, int __val) __THROW;
Packit 6c4009
Packit 6c4009
/* Release all but __pad bytes of freed top-most memory back to the
Packit 6c4009
   system. Return 1 if successful, else 0. */
Packit 6c4009
extern int malloc_trim (size_t __pad) __THROW;
Packit 6c4009
Packit 6c4009
/* Report the number of usable allocated bytes associated with allocated
Packit 6c4009
   chunk __ptr. */
Packit 6c4009
extern size_t malloc_usable_size (void *__ptr) __THROW;
Packit 6c4009
Packit 6c4009
/* Prints brief summary statistics on stderr. */
Packit 6c4009
extern void malloc_stats (void) __THROW;
Packit 6c4009
Packit 6c4009
/* Output information about state of allocator to stream FP.  */
Packit 6c4009
extern int malloc_info (int __options, FILE *__fp) __THROW;
Packit 6c4009
Packit 6c4009
/* Hooks for debugging and user-defined versions. */
Packit 6c4009
extern void (*__MALLOC_HOOK_VOLATILE __free_hook) (void *__ptr,
Packit 6c4009
                                                   const void *)
Packit 6c4009
__MALLOC_DEPRECATED;
Packit 6c4009
extern void *(*__MALLOC_HOOK_VOLATILE __malloc_hook)(size_t __size,
Packit 6c4009
                                                     const void *)
Packit 6c4009
__MALLOC_DEPRECATED;
Packit 6c4009
extern void *(*__MALLOC_HOOK_VOLATILE __realloc_hook)(void *__ptr,
Packit 6c4009
                                                      size_t __size,
Packit 6c4009
                                                      const void *)
Packit 6c4009
__MALLOC_DEPRECATED;
Packit 6c4009
extern void *(*__MALLOC_HOOK_VOLATILE __memalign_hook)(size_t __alignment,
Packit 6c4009
                                                       size_t __size,
Packit 6c4009
                                                       const void *)
Packit 6c4009
__MALLOC_DEPRECATED;
Packit 6c4009
extern void (*__MALLOC_HOOK_VOLATILE __after_morecore_hook) (void);
Packit 6c4009
Packit 6c4009
/* Activate a standard set of debugging hooks. */
Packit 6c4009
extern void __malloc_check_init (void) __THROW __MALLOC_DEPRECATED;
Packit 6c4009
Packit 6c4009
Packit 6c4009
__END_DECLS
Packit 6c4009
#endif /* malloc.h */