home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 4 / DATAFILE_PDCD4.iso / unix / armlinux / alpha / PARTITIONS / USR_GZ / usr / include / malloc.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-14  |  3.7 KB  |  114 lines

  1. /* Declarations for `malloc' and friends.
  2.    Copyright 1990, 1991, 1992 Free Software Foundation, Inc.
  3.           Written May 1989 by Mike Haertel.
  4.  
  5. This library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Library General Public License as
  7. published by the Free Software Foundation; either version 2 of the
  8. License, or (at your option) any later version.
  9.  
  10. This library is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13. Library General Public License for more details.
  14.  
  15. You should have received a copy of the GNU Library General Public
  16. License along with this library; see the file COPYING.LIB.  If
  17. not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  18. Cambridge, MA 02139, USA.
  19.  
  20.    The author may be reached (Email) at the address mike@ai.mit.edu,
  21.    or (US mail) as Mike Haertel c/o Free Software Foundation.  */
  22.  
  23. #ifndef _MALLOC_H
  24. #define _MALLOC_H    1
  25.  
  26. #include <features.h>
  27.  
  28. #ifndef    NULL
  29. #ifdef __cplusplus
  30. #define    NULL    0
  31. #else
  32. #define    NULL    ((void *) 0)
  33. #endif
  34. #endif
  35.  
  36. #ifdef    __STDC__
  37. #include <stddef.h>
  38. #else
  39. #undef    size_t
  40. #define    size_t        unsigned int
  41. #undef    ptrdiff_t
  42. #define    ptrdiff_t    int
  43. #endif
  44.  
  45. /* For backward compatibilities and X11R5 */
  46. #if (defined(MALLOC_0_RETURNS_NULL) || defined(NO_FIX_MALLOC)) \
  47.     && !defined(__MALLOC_0_RETURNS_NULL)
  48. #define __MALLOC_0_RETURNS_NULL
  49. #endif
  50.  
  51. __BEGIN_DECLS
  52.  
  53. #if defined(_STDLIB_H) && !defined(__MALLOC_0_RETURNS_NULL)
  54. /* Allocate SIZE bytes of memory.  */
  55. static void * malloc __P ((size_t __size));
  56. /* Allocate NMEMB elements of SIZE bytes each, all initialized to 0.  */
  57. static void * calloc __P ((size_t __nmemb, size_t __size));
  58. #else
  59. /* Allocate SIZE bytes of memory.  */
  60. extern __ptr_t malloc __P ((size_t __size));
  61. /* Allocate NMEMB elements of SIZE bytes each, all initialized to 0.  */
  62. extern __ptr_t calloc __P ((size_t __nmemb, size_t __size));
  63. #endif
  64. /* Re-allocate the previously allocated block
  65.    in __ptr_t, making the new block SIZE bytes long.  */
  66. extern __ptr_t realloc __P ((__ptr_t __ptr, size_t __size));
  67. /* Free a block allocated by `malloc', `realloc' or `calloc'.  */
  68. extern void free __P ((__ptr_t __ptr));
  69.  
  70. /* Allocate SIZE bytes allocated to ALIGNMENT bytes.  */
  71. extern __ptr_t memalign __P ((size_t __alignment, size_t __size));
  72.  
  73. /* Allocate SIZE bytes on a page boundary.  */
  74. extern __ptr_t valloc __P ((size_t __size));
  75.  
  76. /* Underlying allocation function; successive calls should
  77.    return contiguous pieces of memory.  */
  78. extern __ptr_t (*__morecore) __P ((ptrdiff_t __size));
  79.  
  80. /* Default value of `__morecore'.  */
  81. extern __ptr_t __default_morecore __P ((ptrdiff_t __size));
  82.  
  83. /* Nonzero if `malloc' has been called and done its initialization.  */
  84. extern int __malloc_initialized;
  85.  
  86. /* Hooks for debugging versions.  */
  87. extern void (*__free_hook) __P ((__ptr_t __ptr));
  88. extern __ptr_t (*__malloc_hook) __P ((size_t __size));
  89. extern __ptr_t (*__realloc_hook) __P ((__ptr_t __ptr, size_t __size));
  90.  
  91. /* Activate a standard collection of debugging hooks.  */
  92. extern void mcheck __P ((void (*__func)(void)));
  93.  
  94. /* Activate a standard collection of tracing hooks.  */
  95. extern void mtrace __P ((void));
  96.  
  97. /* Statistics available to the user.  */
  98. struct mstats
  99.   {
  100.     size_t bytes_total;        /* Total size of the heap. */
  101.     size_t chunks_used;        /* Chunks allocated by the user. */
  102.     size_t bytes_used;        /* Byte total of user-allocated chunks. */
  103.     size_t chunks_free;        /* Chunks in the free list. */
  104.     size_t bytes_free;        /* Byte total of chunks in the free list. */
  105.   };
  106.  
  107. /* Pick up the current statistics. */
  108. extern struct mstats mstats __P ((void));
  109.  
  110. __END_DECLS
  111.  
  112.  
  113. #endif /* malloc.h  */
  114.