ReactOS 0.4.15-dev-8100-g1887773
heap.c
Go to the documentation of this file.
1/*
2 * msvcrt.dll heap functions
3 *
4 * Copyright 2000 Jon Griffiths
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 *
20 * Note: Win32 heap operations are MT safe. We only lock the new
21 * handler and non atomic heap operations
22 */
23
24#include <precomp.h>
25#include <malloc.h>
26
27#define MSVCRT_size_t size_t
28#define MSVCRT_intptr_t intptr_t
29#define MSVCRT_wchar_t wchar_t
30#define MSVCRT__HEAPBADNODE _HEAPBADNODE
31#define MSVCRT__HEAPOK _HEAPOK
32#define MSVCRT__HEAPEND _HEAPEND
33#define MSVCRT__FREEENTRY _FREEENTRY
34#define MSVCRT__USEDENTRY _USEDENTRY
35#define MSVCRT__HEAPBADBEGIN _HEAPBADBEGIN
36#define MSVCRT_EINVAL EINVAL
37#define MSVCRT_ENOSYS ENOSYS
38#define MSVCRT_ENOMEM ENOMEM
39#define MSVCRT_ERANGE ERANGE
40#define MSVCRT__TRUNCATE _TRUNCATE
41#define MSVCRT__heapinfo _heapinfo
42#define MSVCRT__errno _errno
43#define MSVCRT_calloc calloc
44#define MSVCRT_malloc malloc
45#define MSVCRT_realloc realloc
46#define MSVCRT_free free
47#define MSVCRT_memcpy_s memcpy_s
48#define MSVCRT_memmove_s memmove_s
49#define MSVCRT_strncpy_s strncpy_s
50#define msvcrt_set_errno _dosmaperr
51
52/* MT */
53#define LOCK_HEAP _mlock( _HEAP_LOCK )
54#define UNLOCK_HEAP _munlock( _HEAP_LOCK )
55
56/* _aligned */
57#define SAVED_PTR(x) ((void *)((DWORD_PTR)((char *)x - sizeof(void *)) & \
58 ~(sizeof(void *) - 1)))
59#define ALIGN_PTR(ptr, alignment, offset) ((void *) \
60 ((((DWORD_PTR)((char *)ptr + alignment + sizeof(void *) + offset)) & \
61 ~(alignment - 1)) - offset))
62
63#define SB_HEAP_ALIGN 16
64
66
68
70static int MSVCRT_new_mode;
71
72/* FIXME - According to documentation it should be 8*1024, at runtime it returns 16 */
73static unsigned int MSVCRT_amblksiz = 16;
74/* FIXME - According to documentation it should be 480 bytes, at runtime default is 0 */
76
78{
80 {
81 void *memblock, *temp, **saved;
82
83 temp = HeapAlloc(sb_heap, flags, size+sizeof(void*)+SB_HEAP_ALIGN);
84 if(!temp) return NULL;
85
86 memblock = ALIGN_PTR(temp, SB_HEAP_ALIGN, 0);
87 saved = SAVED_PTR(memblock);
88 *saved = temp;
89 return memblock;
90 }
91
92 return HeapAlloc(heap, flags, size);
93}
94
96{
97 if(sb_heap && ptr && !HeapValidate(heap, 0, ptr))
98 {
99 /* TODO: move data to normal heap if it exceeds sbh_threshold limit */
100 void *memblock, *temp, **saved;
101 MSVCRT_size_t old_padding, new_padding, old_size;
102
103 saved = SAVED_PTR(ptr);
104 old_padding = (char*)ptr - (char*)*saved;
105 old_size = HeapSize(sb_heap, 0, *saved);
106 if(old_size == -1)
107 return NULL;
108 old_size -= old_padding;
109
110 temp = HeapReAlloc(sb_heap, flags, *saved, size+sizeof(void*)+SB_HEAP_ALIGN);
111 if(!temp) return NULL;
112
113 memblock = ALIGN_PTR(temp, SB_HEAP_ALIGN, 0);
114 saved = SAVED_PTR(memblock);
115 new_padding = (char*)memblock - (char*)temp;
116
117 if(new_padding != old_padding)
118 memmove(memblock, (char*)temp+old_padding, old_size>size ? size : old_size);
119
120 *saved = temp;
121 return memblock;
122 }
123
124 return HeapReAlloc(heap, flags, ptr, size);
125}
126
128{
129 if(sb_heap && ptr && !HeapValidate(heap, 0, ptr))
130 {
131 void **saved = SAVED_PTR(ptr);
132 return HeapFree(sb_heap, 0, *saved);
133 }
134
135 return HeapFree(heap, 0, ptr);
136}
137
139{
140 if(sb_heap && ptr && !HeapValidate(heap, 0, ptr))
141 {
142 void **saved = SAVED_PTR(ptr);
143 return HeapSize(sb_heap, 0, *saved);
144 }
145
146 return HeapSize(heap, 0, ptr);
147}
148
149/*********************************************************************
150 * ??2@YAPAXI@Z (MSVCRT.@)
151 */
153{
154 void *retval;
155 int freed;
157
158 do
159 {
160 retval = msvcrt_heap_alloc(0, size);
161 if(retval)
162 {
163 TRACE("(%ld) returning %p\n", size, retval);
164 return retval;
165 }
166
167 LOCK_HEAP;
169 if(handler)
170 freed = (*handler)(size);
171 else
172 freed = 0;
174 } while(freed);
175
176 TRACE("(%ld) out of memory\n", size);
177#if _MSVCR_VER >= 80
178 throw_exception(EXCEPTION_BAD_ALLOC, 0, "bad allocation");
179#endif
180 return NULL;
181}
182
183
184/*********************************************************************
185 * ??2@YAPAXIHPBDH@Z (MSVCRT.@)
186 */
188{
189 return MSVCRT_operator_new( size );
190}
191
192
193/*********************************************************************
194 * ??3@YAXPAX@Z (MSVCRT.@)
195 */
197{
198 TRACE("(%p)\n", mem);
200}
201
202
203/*********************************************************************
204 * ?_query_new_handler@@YAP6AHI@ZXZ (MSVCRT.@)
205 */
207{
208 return MSVCRT_new_handler;
209}
210
211
212/*********************************************************************
213 * ?_query_new_mode@@YAHXZ (MSVCRT.@)
214 */
216{
217 return MSVCRT_new_mode;
218}
219
220/*********************************************************************
221 * ?_set_new_handler@@YAP6AHI@ZP6AHI@Z@Z (MSVCRT.@)
222 */
224{
225 MSVCRT_new_handler_func old_handler;
226 LOCK_HEAP;
227 old_handler = MSVCRT_new_handler;
230 return old_handler;
231}
232
233/*********************************************************************
234 * ?set_new_handler@@YAP6AXXZP6AXXZ@Z (MSVCRT.@)
235 */
237{
238 TRACE("(%p)\n",func);
240 return NULL;
241}
242
243/*********************************************************************
244 * ?_set_new_mode@@YAHH@Z (MSVCRT.@)
245 */
247{
248 int old_mode;
249 LOCK_HEAP;
250 old_mode = MSVCRT_new_mode;
253 return old_mode;
254}
255
256/*********************************************************************
257 * _callnewh (MSVCRT.@)
258 */
260{
261 int ret = 0;
263 if(handler)
264 ret = (*handler)(size) ? 1 : 0;
265 return ret;
266}
267
268/*********************************************************************
269 * _expand (MSVCRT.@)
270 */
272{
274}
275
276/*********************************************************************
277 * _heapchk (MSVCRT.@)
278 */
280{
281 if (!HeapValidate(heap, 0, NULL) ||
282 (sb_heap && !HeapValidate(sb_heap, 0, NULL)))
283 {
285 return MSVCRT__HEAPBADNODE;
286 }
287 return MSVCRT__HEAPOK;
288}
289
290/*********************************************************************
291 * _heapmin (MSVCRT.@)
292 */
294{
295 if (!HeapCompact( heap, 0 ) ||
296 (sb_heap && !HeapCompact( sb_heap, 0 )))
297 {
300 return -1;
301 }
302 return 0;
303}
304
305/*********************************************************************
306 * _heapwalk (MSVCRT.@)
307 */
309{
311
312 if (sb_heap)
313 FIXME("small blocks heap not supported\n");
314
315 LOCK_HEAP;
316 phe.lpData = next->_pentry;
317 phe.cbData = (DWORD)next->_size;
318 phe.wFlags = next->_useflag == MSVCRT__USEDENTRY ? PROCESS_HEAP_ENTRY_BUSY : 0;
319
320 if (phe.lpData && phe.wFlags & PROCESS_HEAP_ENTRY_BUSY &&
321 !HeapValidate( heap, 0, phe.lpData ))
322 {
325 return MSVCRT__HEAPBADNODE;
326 }
327
328 do
329 {
330 if (!HeapWalk( heap, &phe ))
331 {
334 return MSVCRT__HEAPEND;
336 if (!phe.lpData)
338 return MSVCRT__HEAPBADNODE;
339 }
341
343 next->_pentry = phe.lpData;
344 next->_size = phe.cbData;
346 return MSVCRT__HEAPOK;
347}
348
349/*********************************************************************
350 * _heapset (MSVCRT.@)
351 */
352int CDECL _heapset(unsigned int value)
353{
354 int retval;
355 struct MSVCRT__heapinfo heap;
356
357 memset( &heap, 0, sizeof(heap) );
358 LOCK_HEAP;
359 while ((retval = _heapwalk(&heap)) == MSVCRT__HEAPOK)
360 {
361 if (heap._useflag == MSVCRT__FREEENTRY)
362 memset(heap._pentry, value, heap._size);
363 }
365 return retval == MSVCRT__HEAPEND? MSVCRT__HEAPOK : retval;
366}
367
368/*********************************************************************
369 * _heapadd (MSVCRT.@)
370 */
372{
373 TRACE("(%p,%ld) unsupported in Win32\n", mem,size);
375 return -1;
376}
377
378/*********************************************************************
379 * _get_heap_handle (MSVCRT.@)
380 */
382{
383 return (MSVCRT_intptr_t)heap;
384}
385
386/*********************************************************************
387 * _msize (MSVCRT.@)
388 */
390{
392 if (size == ~(MSVCRT_size_t)0)
393 {
394 WARN(":Probably called with non wine-allocated memory, ret = -1\n");
395 /* At least the Win32 crtdll/msvcrt also return -1 in this case */
396 }
397 return size;
398}
399
400#if _MSVCR_VER>=80
401/*********************************************************************
402 * _aligned_msize (MSVCR80.@)
403 */
404size_t CDECL _aligned_msize(void *p, MSVCRT_size_t alignment, MSVCRT_size_t offset)
405{
406 void **alloc_ptr;
407
408 if(!MSVCRT_CHECK_PMT(p)) return -1;
409
410 if(alignment < sizeof(void*))
411 alignment = sizeof(void*);
412
413 alloc_ptr = SAVED_PTR(p);
414 return _msize(*alloc_ptr)-alignment-sizeof(void*);
415}
416#endif
417
418/*********************************************************************
419 * calloc (MSVCRT.@)
420 */
422{
424
425 if (size && bytes / size != count)
426 {
428 return NULL;
429 }
430
432}
433
434#if _MSVCR_VER>=140
435/*********************************************************************
436 * _calloc_base (UCRTBASE.@)
437 */
438void* CDECL _calloc_base(MSVCRT_size_t count, MSVCRT_size_t size)
439{
440 return MSVCRT_calloc(count, size);
441}
442#endif
443
444/*********************************************************************
445 * free (MSVCRT.@)
446 */
448{
450}
451
452#if _MSVCR_VER>=140
453/*********************************************************************
454 * _free_base (UCRTBASE.@)
455 */
456void CDECL _free_base(void* ptr)
457{
459}
460#endif
461
462/*********************************************************************
463 * malloc (MSVCRT.@)
464 */
466{
467 void *ret = msvcrt_heap_alloc(0, size);
468 if (!ret)
470 return ret;
471}
472
473#if _MSVCR_VER>=140
474/*********************************************************************
475 * _malloc_base (UCRTBASE.@)
476 */
477void* CDECL _malloc_base(MSVCRT_size_t size)
478{
479 return MSVCRT_malloc(size);
480}
481#endif
482
483/*********************************************************************
484 * realloc (MSVCRT.@)
485 */
487{
488 if (!ptr) return MSVCRT_malloc(size);
489 if (size) return msvcrt_heap_realloc(0, ptr, size);
491 return NULL;
492}
493
494#if _MSVCR_VER>=140
495/*********************************************************************
496 * _realloc_base (UCRTBASE.@)
497 */
498void* CDECL _realloc_base(void* ptr, MSVCRT_size_t size)
499{
500 return MSVCRT_realloc(ptr, size);
501}
502#endif
503
504#if _MSVCR_VER>=80
505/*********************************************************************
506 * _recalloc (MSVCR80.@)
507 */
508void* CDECL _recalloc(void *mem, MSVCRT_size_t num, MSVCRT_size_t size)
509{
510 MSVCRT_size_t old_size;
511 void *ret;
512
513 if(!mem)
514 return MSVCRT_calloc(num, size);
515
516 size = num*size;
517 old_size = _msize(mem);
518
520 if(!ret) {
522 return NULL;
523 }
524
525 if(size>old_size)
526 memset((BYTE*)ret+old_size, 0, size-old_size);
527 return ret;
528}
529#endif
530
531/*********************************************************************
532 * __p__amblksiz (MSVCRT.@)
533 */
534unsigned int* CDECL __p__amblksiz(void)
535{
536 return &MSVCRT_amblksiz;
537}
538
539/*********************************************************************
540 * _get_sbh_threshold (MSVCRT.@)
541 */
543{
545}
546
547/*********************************************************************
548 * _set_sbh_threshold (MSVCRT.@)
549 */
551{
552#ifdef _WIN64
553 return 0;
554#else
555 if(threshold > 1016)
556 return 0;
557
558 if(!sb_heap)
559 {
560 sb_heap = HeapCreate(0, 0, 0);
561 if(!sb_heap)
562 return 0;
563 }
564
565 MSVCRT_sbh_threshold = (threshold+0xf) & ~0xf;
566 return 1;
567#endif
568}
569
570/*********************************************************************
571 * _aligned_free (MSVCRT.@)
572 */
573void CDECL _aligned_free(void *memblock)
574{
575 TRACE("(%p)\n", memblock);
576
577 if (memblock)
578 {
579 void **saved = SAVED_PTR(memblock);
580 MSVCRT_free(*saved);
581 }
582}
583
584/*********************************************************************
585 * _aligned_offset_malloc (MSVCRT.@)
586 */
588{
589 void *memblock, *temp, **saved;
590 TRACE("(%lu, %lu, %lu)\n", size, alignment, offset);
591
592 /* alignment must be a power of 2 */
593 if ((alignment & (alignment - 1)) != 0)
594 {
596 return NULL;
597 }
598
599 /* offset must be less than size */
600 if (offset && offset >= size)
601 {
603 return NULL;
604 }
605
606 /* don't align to less than void pointer size */
607 if (alignment < sizeof(void *))
608 alignment = sizeof(void *);
609
610 /* allocate enough space for void pointer and alignment */
611 temp = MSVCRT_malloc(size + alignment + sizeof(void *));
612
613 if (!temp)
614 return NULL;
615
616 /* adjust pointer for proper alignment and offset */
617 memblock = ALIGN_PTR(temp, alignment, offset);
618
619 /* Save the real allocation address below returned address */
620 /* so it can be found later to free. */
621 saved = SAVED_PTR(memblock);
622 *saved = temp;
623
624 return memblock;
625}
626
627/*********************************************************************
628 * _aligned_malloc (MSVCRT.@)
629 */
631{
632 TRACE("(%lu, %lu)\n", size, alignment);
633 return _aligned_offset_malloc(size, alignment, 0);
634}
635
636/*********************************************************************
637 * _aligned_offset_realloc (MSVCRT.@)
638 */
641{
642 void * temp, **saved;
643 MSVCRT_size_t old_padding, new_padding, old_size;
644 TRACE("(%p, %lu, %lu, %lu)\n", memblock, size, alignment, offset);
645
646 if (!memblock)
647 return _aligned_offset_malloc(size, alignment, offset);
648
649 /* alignment must be a power of 2 */
650 if ((alignment & (alignment - 1)) != 0)
651 {
653 return NULL;
654 }
655
656 /* offset must be less than size */
657 if (offset >= size)
658 {
660 return NULL;
661 }
662
663 if (size == 0)
664 {
665 _aligned_free(memblock);
666 return NULL;
667 }
668
669 /* don't align to less than void pointer size */
670 if (alignment < sizeof(void *))
671 alignment = sizeof(void *);
672
673 /* make sure alignment and offset didn't change */
674 saved = SAVED_PTR(memblock);
675 if (memblock != ALIGN_PTR(*saved, alignment, offset))
676 {
678 return NULL;
679 }
680
681 old_padding = (char *)memblock - (char *)*saved;
682
683 /* Get previous size of block */
684 old_size = _msize(*saved);
685 if (old_size == -1)
686 {
687 /* It seems this function was called with an invalid pointer. Bail out. */
688 return NULL;
689 }
690
691 /* Adjust old_size to get amount of actual data in old block. */
692 if (old_size < old_padding)
693 {
694 /* Shouldn't happen. Something's weird, so bail out. */
695 return NULL;
696 }
697 old_size -= old_padding;
698
699 temp = MSVCRT_realloc(*saved, size + alignment + sizeof(void *));
700
701 if (!temp)
702 return NULL;
703
704 /* adjust pointer for proper alignment and offset */
705 memblock = ALIGN_PTR(temp, alignment, offset);
706
707 /* Save the real allocation address below returned address */
708 /* so it can be found later to free. */
709 saved = SAVED_PTR(memblock);
710
711 new_padding = (char *)memblock - (char *)temp;
712
713/*
714 Memory layout of old block is as follows:
715 +-------+---------------------+-+--------------------------+-----------+
716 | ... | "old_padding" bytes | | ... "old_size" bytes ... | ... |
717 +-------+---------------------+-+--------------------------+-----------+
718 ^ ^ ^
719 | | |
720 *saved saved memblock
721
722 Memory layout of new block is as follows:
723 +-------+-----------------------------+-+----------------------+-------+
724 | ... | "new_padding" bytes | | ... "size" bytes ... | ... |
725 +-------+-----------------------------+-+----------------------+-------+
726 ^ ^ ^
727 | | |
728 temp saved memblock
729
730 However, in the new block, actual data is still written as follows
731 (because it was copied by MSVCRT_realloc):
732 +-------+---------------------+--------------------------------+-------+
733 | ... | "old_padding" bytes | ... "old_size" bytes ... | ... |
734 +-------+---------------------+--------------------------------+-------+
735 ^ ^ ^
736 | | |
737 temp saved memblock
738
739 Therefore, min(old_size,size) bytes of actual data have to be moved
740 from the offset they were at in the old block (temp + old_padding),
741 to the offset they have to be in the new block (temp + new_padding == memblock).
742*/
743 if (new_padding != old_padding)
744 memmove((char *)memblock, (char *)temp + old_padding, (old_size < size) ? old_size : size);
745
746 *saved = temp;
747
748 return memblock;
749}
750
751/*********************************************************************
752 * _aligned_realloc (MSVCRT.@)
753 */
754void * CDECL _aligned_realloc(void *memblock, MSVCRT_size_t size, MSVCRT_size_t alignment)
755{
756 TRACE("(%p, %lu, %lu)\n", memblock, size, alignment);
757 return _aligned_offset_realloc(memblock, size, alignment, 0);
758}
759
760/*********************************************************************
761 * memmove_s (MSVCRT.@)
762 */
764{
765 TRACE("(%p %lu %p %lu)\n", dest, numberOfElements, src, count);
766
767 if(!count)
768 return 0;
769
770 if (!MSVCRT_CHECK_PMT(dest != NULL)) return MSVCRT_EINVAL;
771 if (!MSVCRT_CHECK_PMT(src != NULL)) return MSVCRT_EINVAL;
773
775 return 0;
776}
777
778#if _MSVCR_VER>=100
779/*********************************************************************
780 * wmemmove_s (MSVCR100.@)
781 */
784{
785 TRACE("(%p %lu %p %lu)\n", dest, numberOfElements, src, count);
786
787 if (!count)
788 return 0;
789
790 /* Native does not seem to conform to 6.7.1.2.3 in
791 * http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1225.pdf
792 * in that it does not zero the output buffer on constraint violation.
793 */
794 if (!MSVCRT_CHECK_PMT(dest != NULL)) return MSVCRT_EINVAL;
795 if (!MSVCRT_CHECK_PMT(src != NULL)) return MSVCRT_EINVAL;
797
799 return 0;
800}
801#endif
802
803/*********************************************************************
804 * memcpy_s (MSVCRT.@)
805 */
807{
808 TRACE("(%p %lu %p %lu)\n", dest, numberOfElements, src, count);
809
810 if(!count)
811 return 0;
812
813 if (!MSVCRT_CHECK_PMT(dest != NULL)) return MSVCRT_EINVAL;
814 if (!MSVCRT_CHECK_PMT(src != NULL))
815 {
817 return MSVCRT_EINVAL;
818 }
820 {
822 return MSVCRT_ERANGE;
823 }
824
826 return 0;
827}
828
829#if _MSVCR_VER>=100
830/*********************************************************************
831 * wmemcpy_s (MSVCR100.@)
832 */
835{
836 TRACE("(%p %lu %p %lu)\n", dest, numberOfElements, src, count);
837
838 if (!count)
839 return 0;
840
841 if (!MSVCRT_CHECK_PMT(dest != NULL)) return MSVCRT_EINVAL;
842
843 if (!MSVCRT_CHECK_PMT(src != NULL)) {
845 return MSVCRT_EINVAL;
846 }
849 return MSVCRT_ERANGE;
850 }
851
853 return 0;
854}
855#endif
856
857/*********************************************************************
858 * strncpy_s (MSVCRT.@)
859 */
861 const char *src, MSVCRT_size_t count)
862{
864
865 TRACE("(%s %lu %s %lu)\n", dest, numberOfElements, src, count);
866
867 if(!count) {
869 *dest = 0;
870 return 0;
871 }
872
873 if (!MSVCRT_CHECK_PMT(dest != NULL)) return MSVCRT_EINVAL;
874 if (!MSVCRT_CHECK_PMT(src != NULL)) return MSVCRT_EINVAL;
876
878 end = count;
879 else
881
882 for(i=0; i<end && src[i]; i++)
883 dest[i] = src[i];
884
885 if(!src[i] || end==count || count==MSVCRT__TRUNCATE) {
886 dest[i] = '\0';
887 return 0;
888 }
889
890 MSVCRT_INVALID_PMT("dest[numberOfElements] is too small", MSVCRT_EINVAL);
891 dest[0] = '\0';
892 return MSVCRT_EINVAL;
893}
894
896{
897#ifdef __REACTOS__
899#else
900 heap = HeapCreate(0, 0, 0);
901#endif
902 return heap != NULL;
903}
904
906{
908 if(sb_heap)
910}
#define DECLSPEC_HOTPATCH
Definition: _mingw.h:243
static unsigned char bytes[4]
Definition: adnsresfilter.c:74
#define FIXME(fmt,...)
Definition: debug.h:114
#define WARN(fmt,...)
Definition: debug.h:115
#define NULL
Definition: types.h:112
#define CDECL
Definition: compat.h:29
#define GetProcessHeap()
Definition: compat.h:736
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102
#define HeapAlloc
Definition: compat.h:733
#define HeapReAlloc
Definition: compat.h:734
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:105
#define HeapFree(x, y, z)
Definition: compat.h:735
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
UINT(* handler)(MSIPACKAGE *)
Definition: action.c:7482
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLuint GLuint end
Definition: gl.h:1545
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLsizeiptr size
Definition: glext.h:5919
GLenum func
Definition: glext.h:6028
GLenum src
Definition: glext.h:6340
GLenum mode
Definition: glext.h:6217
GLbitfield flags
Definition: glext.h:7161
GLfloat GLfloat p
Definition: glext.h:8902
GLuint GLuint num
Definition: glext.h:9618
GLintptr offset
Definition: glext.h:5920
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
HANDLE WINAPI HeapCreate(DWORD flOptions, SIZE_T dwInitialSize, SIZE_T dwMaximumSize)
Definition: heapmem.c:45
SIZE_T WINAPI HeapCompact(HANDLE hHeap, DWORD dwFlags)
Definition: heapmem.c:145
BOOL WINAPI HeapValidate(HANDLE hHeap, DWORD dwFlags, LPCVOID lpMem)
Definition: heapmem.c:156
BOOL WINAPI HeapDestroy(HANDLE hHeap)
Definition: heapmem.c:85
BOOL WINAPI HeapWalk(HANDLE hHeap, LPPROCESS_HEAP_ENTRY lpEntry)
Definition: heapmem.c:291
if(dx< 0)
Definition: linetemp.h:194
_CRTIMP int __cdecl _set_sbh_threshold(_In_ size_t _NewValue)
_Check_return_ _CRTIMP size_t __cdecl _get_sbh_threshold(void)
Definition: heap.c:542
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
static PVOID ptr
Definition: dispmode.c:27
#define MSVCRT_INVALID_PMT(x)
Definition: mbstowcs_s.c:25
#define MSVCRT_CHECK_PMT(x)
Definition: mbstowcs_s.c:26
unsigned long MSVCRT_size_t
Definition: msvcrt.h:67
unsigned short MSVCRT_wchar_t
Definition: msvcrt.h:55
long MSVCRT_intptr_t
Definition: msvcrt.h:68
static size_t numberOfElements
Definition: string.c:87
static char * dest
Definition: rtl.c:135
#define DWORD
Definition: nt_native.h:44
#define HEAP_REALLOC_IN_PLACE_ONLY
Definition: nt_native.h:1696
static unsigned __int64 next
Definition: rand_nt.c:6
static calc_node_t temp
Definition: rpn_ieee.c:38
#define MSVCRT_CHECK_PMT_ERR(x, err)
Definition: safecrt.h:15
#define MSVCRT_ENOSYS
Definition: heap.c:37
MSVCRT_new_handler_func CDECL MSVCRT__query_new_handler(void)
Definition: heap.c:206
int CDECL _heapmin(void)
Definition: heap.c:293
void *CDECL _aligned_offset_realloc(void *memblock, MSVCRT_size_t size, MSVCRT_size_t alignment, MSVCRT_size_t offset)
Definition: heap.c:639
void *CDECL _aligned_malloc(MSVCRT_size_t size, MSVCRT_size_t alignment)
Definition: heap.c:630
void *CDECL _aligned_offset_malloc(MSVCRT_size_t size, MSVCRT_size_t alignment, MSVCRT_size_t offset)
Definition: heap.c:587
#define MSVCRT_ERANGE
Definition: heap.c:39
static MSVCRT_size_t MSVCRT_sbh_threshold
Definition: heap.c:75
#define MSVCRT__USEDENTRY
Definition: heap.c:34
#define MSVCRT__TRUNCATE
Definition: heap.c:40
#define MSVCRT__FREEENTRY
Definition: heap.c:33
#define MSVCRT_EINVAL
Definition: heap.c:36
void *CDECL _expand(void *mem, MSVCRT_size_t size)
Definition: heap.c:271
MSVCRT_new_handler_func CDECL MSVCRT__set_new_handler(MSVCRT_new_handler_func func)
Definition: heap.c:223
void *CDECL DECLSPEC_HOTPATCH MSVCRT_operator_new(MSVCRT_size_t size)
Definition: heap.c:152
static HANDLE heap
Definition: heap.c:65
#define MSVCRT_free
Definition: heap.c:46
BOOL msvcrt_init_heap(void)
Definition: heap.c:895
static int MSVCRT_new_mode
Definition: heap.c:70
static MSVCRT_size_t msvcrt_heap_size(void *ptr)
Definition: heap.c:138
#define MSVCRT__errno
Definition: heap.c:42
int(CDECL * MSVCRT_new_handler_func)(MSVCRT_size_t size)
Definition: heap.c:67
#define MSVCRT__HEAPOK
Definition: heap.c:31
#define SB_HEAP_ALIGN
Definition: heap.c:63
int CDECL _heapchk(void)
Definition: heap.c:279
static void * msvcrt_heap_alloc(DWORD flags, MSVCRT_size_t size)
Definition: heap.c:77
int CDECL _heapset(unsigned int value)
Definition: heap.c:352
MSVCRT_intptr_t CDECL _get_heap_handle(void)
Definition: heap.c:381
void *CDECL MSVCRT_operator_new_dbg(MSVCRT_size_t size, int type, const char *file, int line)
Definition: heap.c:187
void msvcrt_destroy_heap(void)
Definition: heap.c:905
MSVCRT_new_handler_func CDECL MSVCRT_set_new_handler(void *func)
Definition: heap.c:236
int CDECL _callnewh(MSVCRT_size_t size)
Definition: heap.c:259
#define MSVCRT__HEAPBADNODE
Definition: heap.c:30
void *CDECL _aligned_realloc(void *memblock, MSVCRT_size_t size, MSVCRT_size_t alignment)
Definition: heap.c:754
static void * msvcrt_heap_realloc(DWORD flags, void *ptr, MSVCRT_size_t size)
Definition: heap.c:95
#define UNLOCK_HEAP
Definition: heap.c:54
#define SAVED_PTR(x)
Definition: heap.c:57
unsigned int *CDECL __p__amblksiz(void)
Definition: heap.c:534
void CDECL DECLSPEC_HOTPATCH MSVCRT_operator_delete(void *mem)
Definition: heap.c:196
#define MSVCRT_strncpy_s
Definition: heap.c:49
static HANDLE sb_heap
Definition: heap.c:65
int CDECL _heapwalk(struct MSVCRT__heapinfo *next)
Definition: heap.c:308
#define MSVCRT_malloc
Definition: heap.c:44
#define MSVCRT_memcpy_s
Definition: heap.c:47
MSVCRT_size_t CDECL _msize(void *mem)
Definition: heap.c:389
static unsigned int MSVCRT_amblksiz
Definition: heap.c:73
static MSVCRT_new_handler_func MSVCRT_new_handler
Definition: heap.c:69
#define ALIGN_PTR(ptr, alignment, offset)
Definition: heap.c:59
#define MSVCRT__HEAPEND
Definition: heap.c:32
void CDECL _aligned_free(void *memblock)
Definition: heap.c:573
int CDECL MSVCRT__query_new_mode(void)
Definition: heap.c:215
#define MSVCRT_ENOMEM
Definition: heap.c:38
#define MSVCRT_calloc
Definition: heap.c:43
int CDECL MSVCRT__set_new_mode(int mode)
Definition: heap.c:246
#define MSVCRT__HEAPBADBEGIN
Definition: heap.c:35
static BOOL msvcrt_heap_free(void *ptr)
Definition: heap.c:127
#define MSVCRT_memmove_s
Definition: heap.c:48
int CDECL _heapadd(void *mem, MSVCRT_size_t size)
Definition: heap.c:371
#define msvcrt_set_errno
Definition: heap.c:50
#define MSVCRT_realloc
Definition: heap.c:45
#define LOCK_HEAP
Definition: heap.c:53
#define memset(x, y, z)
Definition: compat.h:39
#define TRACE(s)
Definition: solgame.cpp:4
Definition: winbase.h:1268
WORD wFlags
Definition: winbase.h:1273
PVOID lpData
Definition: winbase.h:1269
DWORD cbData
Definition: winbase.h:1270
Definition: fci.c:127
Definition: parser.c:49
Definition: mem.c:156
Definition: pdh_main.c:94
int ret
SIZE_T WINAPI HeapSize(HANDLE, DWORD, LPCVOID)
#define PROCESS_HEAP_UNCOMMITTED_RANGE
Definition: winbase.h:335
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define PROCESS_HEAP_ENTRY_BUSY
Definition: winbase.h:336
#define PROCESS_HEAP_REGION
Definition: winbase.h:334
unsigned char BYTE
Definition: xxhash.c:193