ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

malloc.h
Go to the documentation of this file.
00001 
00006 #ifndef _MALLOC_H_
00007 #define _MALLOC_H_
00008 
00009 #include <crtdefs.h>
00010 
00011 #pragma pack(push,_CRT_PACKING)
00012 
00013 #ifndef _MM_MALLOC_H_INCLUDED
00014 #define _MM_MALLOC_H_INCLUDED
00015 #endif
00016 
00017 #ifdef __cplusplus
00018 extern "C" {
00019 #endif
00020 
00021 #ifdef _WIN64
00022 #define _HEAP_MAXREQ 0xFFFFFFFFFFFFFFE0
00023 #else
00024 #define _HEAP_MAXREQ 0xFFFFFFE0
00025 #endif
00026 
00027 #ifndef _STATIC_ASSERT
00028 #define _STATIC_ASSERT(expr) extern char (*static_assert(void)) [(expr) ? 1 : -1]
00029 #endif
00030 
00031 /* Return codes for _heapwalk()  */
00032 #define _HEAPEMPTY (-1)
00033 #define _HEAPOK (-2)
00034 #define _HEAPBADBEGIN (-3)
00035 #define _HEAPBADNODE (-4)
00036 #define _HEAPEND (-5)
00037 #define _HEAPBADPTR (-6)
00038 
00039 /* Values for _heapinfo.useflag */
00040 #define _FREEENTRY 0
00041 #define _USEDENTRY 1
00042 
00043 #ifndef _HEAPINFO_DEFINED
00044 #define _HEAPINFO_DEFINED
00045  /* The structure used to walk through the heap with _heapwalk.  */
00046   typedef struct _heapinfo {
00047     int *_pentry;
00048     size_t _size;
00049     int _useflag;
00050   } _HEAPINFO;
00051 #endif
00052 
00053   extern unsigned int _amblksiz;
00054 
00055 #define _mm_free(a) _aligned_free(a)
00056 #define _mm_malloc(a,b) _aligned_malloc(a,b)
00057 
00058 #ifndef _CRT_ALLOCATION_DEFINED
00059 #define _CRT_ALLOCATION_DEFINED
00060   void *__cdecl calloc(size_t _NumOfElements,size_t _SizeOfElements);
00061   void __cdecl free(void *_Memory);
00062   void *__cdecl malloc(size_t _Size);
00063   void *__cdecl realloc(void *_Memory,size_t _NewSize);
00064   _CRTIMP void *__cdecl _recalloc(void *_Memory,size_t _Count,size_t _Size);
00065   /*    _CRTIMP void __cdecl _aligned_free(void *_Memory);
00066   _CRTIMP void *__cdecl _aligned_malloc(size_t _Size,size_t _Alignment); */
00067   _CRTIMP void *__cdecl _aligned_offset_malloc(size_t _Size,size_t _Alignment,size_t _Offset);
00068   _CRTIMP void *__cdecl _aligned_realloc(void *_Memory,size_t _Size,size_t _Alignment);
00069   _CRTIMP void *__cdecl _aligned_recalloc(void *_Memory,size_t _Count,size_t _Size,size_t _Alignment);
00070   _CRTIMP void *__cdecl _aligned_offset_realloc(void *_Memory,size_t _Size,size_t _Alignment,size_t _Offset);
00071   _CRTIMP void *__cdecl _aligned_offset_recalloc(void *_Memory,size_t _Count,size_t _Size,size_t _Alignment,size_t _Offset);
00072 #endif
00073 
00074 #define _MAX_WAIT_MALLOC_CRT 60000
00075 
00076   _CRTIMP int __cdecl _resetstkoflw (void);
00077   _CRTIMP unsigned long __cdecl _set_malloc_crt_max_wait(unsigned long _NewValue);
00078 
00079   _CRTIMP void *__cdecl _expand(void *_Memory,size_t _NewSize);
00080   _CRTIMP size_t __cdecl _msize(void *_Memory);
00081 #ifdef __GNUC__
00082 #undef _alloca
00083 #define _alloca(x) __builtin_alloca((x))
00084 #else
00085   void *__cdecl _alloca(size_t _Size);
00086 #endif
00087   _CRTIMP size_t __cdecl _get_sbh_threshold(void);
00088   _CRTIMP int __cdecl _set_sbh_threshold(size_t _NewValue);
00089   _CRTIMP errno_t __cdecl _set_amblksiz(size_t _Value);
00090   _CRTIMP errno_t __cdecl _get_amblksiz(size_t *_Value);
00091   _CRTIMP int __cdecl _heapadd(void *_Memory,size_t _Size);
00092   _CRTIMP int __cdecl _heapchk(void);
00093   _CRTIMP int __cdecl _heapmin(void);
00094   _CRTIMP int __cdecl _heapset(unsigned int _Fill);
00095   _CRTIMP int __cdecl _heapwalk(_HEAPINFO *_EntryInfo);
00096   _CRTIMP size_t __cdecl _heapused(size_t *_Used,size_t *_Commit);
00097   _CRTIMP intptr_t __cdecl _get_heap_handle(void);
00098 
00099 #define _ALLOCA_S_THRESHOLD 1024
00100 #define _ALLOCA_S_STACK_MARKER 0xCCCC
00101 #define _ALLOCA_S_HEAP_MARKER 0xDDDD
00102 
00103 #if(defined(_X86_) && !defined(__x86_64))
00104 #define _ALLOCA_S_MARKER_SIZE 8
00105 #elif defined(__ia64__) || defined(__x86_64)
00106 #define _ALLOCA_S_MARKER_SIZE 16
00107 #elif defined(__arm__)
00108 #define _ALLOCA_S_MARKER_SIZE 8
00109 #endif
00110 
00111 #if !defined(RC_INVOKED)
00112   static __inline void *_MarkAllocaS(void *_Ptr,unsigned int _Marker) {
00113     if(_Ptr) {
00114       *((unsigned int*)_Ptr) = _Marker;
00115       _Ptr = (char*)_Ptr + _ALLOCA_S_MARKER_SIZE;
00116     }
00117     return _Ptr;
00118   }
00119 #endif
00120 
00121 #undef _malloca
00122 #define _malloca(size) \
00123   ((((size) + _ALLOCA_S_MARKER_SIZE) <= _ALLOCA_S_THRESHOLD) ? \
00124     _MarkAllocaS(_alloca((size) + _ALLOCA_S_MARKER_SIZE),_ALLOCA_S_STACK_MARKER) : \
00125     _MarkAllocaS(malloc((size) + _ALLOCA_S_MARKER_SIZE),_ALLOCA_S_HEAP_MARKER))
00126 #undef _FREEA_INLINE
00127 #define _FREEA_INLINE
00128 
00129 #ifndef RC_INVOKED
00130 #undef _freea
00131   static __inline void __cdecl _freea(void *_Memory) {
00132     unsigned int _Marker;
00133     if(_Memory) {
00134       _Memory = (char*)_Memory - _ALLOCA_S_MARKER_SIZE;
00135       _Marker = *(unsigned int *)_Memory;
00136       if(_Marker==_ALLOCA_S_HEAP_MARKER) {
00137     free(_Memory);
00138       }
00139 #ifdef _ASSERTE
00140       else if(_Marker!=_ALLOCA_S_STACK_MARKER) {
00141     _ASSERTE(("Corrupted pointer passed to _freea",0));
00142       }
00143 #endif
00144     }
00145   }
00146 #endif /* RC_INVOKED */
00147 
00148 #ifndef NO_OLDNAMES
00149 #define alloca _alloca
00150 #endif
00151 
00152 #ifdef HEAPHOOK
00153 #ifndef _HEAPHOOK_DEFINED
00154 #define _HEAPHOOK_DEFINED
00155   typedef int (__cdecl *_HEAPHOOK)(int,size_t,void *,void **);
00156 #endif
00157 
00158   _CRTIMP _HEAPHOOK __cdecl _setheaphook(_HEAPHOOK _NewHook);
00159 
00160 #define _HEAP_MALLOC 1
00161 #define _HEAP_CALLOC 2
00162 #define _HEAP_FREE 3
00163 #define _HEAP_REALLOC 4
00164 #define _HEAP_MSIZE 5
00165 #define _HEAP_EXPAND 6
00166 #endif
00167 
00168 #ifdef __cplusplus
00169 }
00170 #endif
00171 
00172 #pragma pack(pop)
00173 
00174 #endif /* _MALLOC_H_ */

Generated on Wed May 23 2012 04:27:51 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.