ReactOS 0.4.16-dev-2104-gb84fa49
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 <malloc.h>
25#include "msvcrt.h"
26#include "mtdll.h"
27#include "wine/debug.h"
28
30
31/* MT */
32#define LOCK_HEAP _lock( _HEAP_LOCK )
33#define UNLOCK_HEAP _unlock( _HEAP_LOCK )
34
35/* _aligned */
36#define SAVED_PTR(x) ((void *)((DWORD_PTR)((char *)x - sizeof(void *)) & \
37 ~(sizeof(void *) - 1)))
38#define ALIGN_PTR(ptr, alignment, offset) ((void *) \
39 ((((DWORD_PTR)((char *)ptr + alignment + sizeof(void *) + offset)) & \
40 ~(alignment - 1)) - offset))
41
42#define SB_HEAP_ALIGN 16
43
45
47
50
51/* FIXME - According to documentation it should be 8*1024, at runtime it returns 16 */
52static unsigned int MSVCRT_amblksiz = 16;
53/* FIXME - According to documentation it should be 480 bytes, at runtime default is 0 */
54static size_t MSVCRT_sbh_threshold = 0;
55
56static void* msvcrt_heap_alloc(DWORD flags, size_t size)
57{
59 {
60 void *memblock, *temp, **saved;
61
62 temp = HeapAlloc(sb_heap, flags, size+sizeof(void*)+SB_HEAP_ALIGN);
63 if(!temp) return NULL;
64
65 memblock = ALIGN_PTR(temp, SB_HEAP_ALIGN, 0);
66 saved = SAVED_PTR(memblock);
67 *saved = temp;
68 return memblock;
69 }
70
71 return HeapAlloc(heap, flags, size);
72}
73
74static void* msvcrt_heap_realloc(DWORD flags, void *ptr, size_t size)
75{
76 if(sb_heap && ptr && !HeapValidate(heap, 0, ptr))
77 {
78 /* TODO: move data to normal heap if it exceeds sbh_threshold limit */
79 void *memblock, *temp, **saved;
80 size_t old_padding, new_padding, old_size;
81
82 saved = SAVED_PTR(ptr);
83 old_padding = (char*)ptr - (char*)*saved;
84 old_size = HeapSize(sb_heap, 0, *saved);
85 if(old_size == -1)
86 return NULL;
87 old_size -= old_padding;
88
89 temp = HeapReAlloc(sb_heap, flags, *saved, size+sizeof(void*)+SB_HEAP_ALIGN);
90 if(!temp) return NULL;
91
92 memblock = ALIGN_PTR(temp, SB_HEAP_ALIGN, 0);
93 saved = SAVED_PTR(memblock);
94 new_padding = (char*)memblock - (char*)temp;
95
96 if(new_padding != old_padding)
97 memmove(memblock, (char*)temp+old_padding, old_size>size ? size : old_size);
98
99 *saved = temp;
100 return memblock;
101 }
102
103 return HeapReAlloc(heap, flags, ptr, size);
104}
105
107{
108 if(sb_heap && ptr && !HeapValidate(heap, 0, ptr))
109 {
110 void **saved = SAVED_PTR(ptr);
111 return HeapFree(sb_heap, 0, *saved);
112 }
113
114 return HeapFree(heap, 0, ptr);
115}
116
117static size_t msvcrt_heap_size(void *ptr)
118{
119 if(sb_heap && ptr && !HeapValidate(heap, 0, ptr))
120 {
121 void **saved = SAVED_PTR(ptr);
122 return HeapSize(sb_heap, 0, *saved);
123 }
124
125 return HeapSize(heap, 0, ptr);
126}
127
128/*********************************************************************
129 * _callnewh (MSVCRT.@)
130 */
132{
133 int ret = 0;
135 if(handler)
136 ret = (*handler)(size) ? 1 : 0;
137 return ret;
138}
139
140/*********************************************************************
141 * ??2@YAPAXI@Z (MSVCRT.@)
142 */
144{
145 void *retval;
146
147 do
148 {
150 if(retval)
151 {
152 TRACE("(%Iu) returning %p\n", size, retval);
153 return retval;
154 }
155 } while(_callnewh(size));
156
157 TRACE("(%Iu) out of memory\n", size);
158#if _MSVCR_VER >= 80
159 throw_bad_alloc();
160#endif
161 return NULL;
162}
163
164
165/*********************************************************************
166 * ??2@YAPAXIHPBDH@Z (MSVCRT.@)
167 */
168void* CDECL operator_new_dbg(size_t size, int type, const char *file, int line)
169{
170 return operator_new( size );
171}
172
173
174/*********************************************************************
175 * ??3@YAXPAX@Z (MSVCRT.@)
176 */
178{
179 TRACE("(%p)\n", mem);
181}
182
183
184/*********************************************************************
185 * ?_query_new_handler@@YAP6AHI@ZXZ (MSVCRT.@)
186 */
188{
189 return MSVCRT_new_handler;
190}
191
192
193/*********************************************************************
194 * ?_query_new_mode@@YAHXZ (MSVCRT.@)
195 */
197{
198 return MSVCRT_new_mode;
199}
200
201/*********************************************************************
202 * ?_set_new_handler@@YAP6AHI@ZP6AHI@Z@Z (MSVCRT.@)
203 */
205{
206 MSVCRT_new_handler_func old_handler;
207 LOCK_HEAP;
208 old_handler = MSVCRT_new_handler;
211 return old_handler;
212}
213
214/*********************************************************************
215 * ?set_new_handler@@YAP6AXXZP6AXXZ@Z (MSVCRT.@)
216 */
218{
219 TRACE("(%p)\n",func);
221 return NULL;
222}
223
224/*********************************************************************
225 * ?_set_new_mode@@YAHH@Z (MSVCRT.@)
226 */
228{
229 if(!MSVCRT_CHECK_PMT(mode == 0 || mode == 1)) return -1;
231}
232
233/*********************************************************************
234 * _expand (MSVCRT.@)
235 */
236void* CDECL _expand(void* mem, size_t size)
237{
239}
240
241/*********************************************************************
242 * _heapchk (MSVCRT.@)
243 */
245{
246 if (!HeapValidate(heap, 0, NULL) ||
247 (sb_heap && !HeapValidate(sb_heap, 0, NULL)))
248 {
250 return _HEAPBADNODE;
251 }
252 return _HEAPOK;
253}
254
255/*********************************************************************
256 * _heapmin (MSVCRT.@)
257 */
259{
260 if (!HeapCompact( heap, 0 ) ||
261 (sb_heap && !HeapCompact( sb_heap, 0 )))
262 {
265 return -1;
266 }
267 return 0;
268}
269
270/*********************************************************************
271 * _heapwalk (MSVCRT.@)
272 */
274{
276
277 if (sb_heap)
278 FIXME("small blocks heap not supported\n");
279
280 LOCK_HEAP;
281 phe.lpData = next->_pentry;
282 phe.cbData = next->_size;
283 phe.wFlags = next->_useflag == _USEDENTRY ? PROCESS_HEAP_ENTRY_BUSY : 0;
284
285 if (phe.lpData && phe.wFlags & PROCESS_HEAP_ENTRY_BUSY &&
286 !HeapValidate( heap, 0, phe.lpData ))
287 {
290 return _HEAPBADNODE;
291 }
292
293 do
294 {
295 if (!HeapWalk( heap, &phe ))
296 {
299 return _HEAPEND;
301 if (!phe.lpData)
302 return _HEAPBADBEGIN;
303 return _HEAPBADNODE;
304 }
306
308 next->_pentry = phe.lpData;
309 next->_size = phe.cbData;
311 return _HEAPOK;
312}
313
314/*********************************************************************
315 * _heapset (MSVCRT.@)
316 */
317int CDECL _heapset(unsigned int value)
318{
319 int retval;
321
322 memset( &heap, 0, sizeof(heap) );
323 LOCK_HEAP;
324 while ((retval = _heapwalk(&heap)) == _HEAPOK)
325 {
326 if (heap._useflag == _FREEENTRY)
327 memset(heap._pentry, value, heap._size);
328 }
330 return retval == _HEAPEND ? _HEAPOK : retval;
331}
332
333/*********************************************************************
334 * _heapadd (MSVCRT.@)
335 */
336int CDECL _heapadd(void* mem, size_t size)
337{
338 TRACE("(%p,%Iu) unsupported in Win32\n", mem,size);
339 *_errno() = ENOSYS;
340 return -1;
341}
342
343/*********************************************************************
344 * _get_heap_handle (MSVCRT.@)
345 */
347{
348 return (intptr_t)heap;
349}
350
351/*********************************************************************
352 * _msize (MSVCRT.@)
353 */
354size_t CDECL _msize(void* mem)
355{
356 size_t size = msvcrt_heap_size(mem);
357 if (size == ~(size_t)0)
358 {
359 WARN(":Probably called with non wine-allocated memory, ret = -1\n");
360 /* At least the Win32 crtdll/msvcrt also return -1 in this case */
361 }
362 return size;
363}
364
365#if _MSVCR_VER>=80
366/*********************************************************************
367 * _aligned_msize (MSVCR80.@)
368 */
369size_t CDECL _aligned_msize(void *p, size_t alignment, size_t offset)
370{
371 void **alloc_ptr;
372
373 if(!MSVCRT_CHECK_PMT(p)) return -1;
374
375 if(alignment < sizeof(void*))
376 alignment = sizeof(void*);
377
378 alloc_ptr = SAVED_PTR(p);
379 return _msize(*alloc_ptr)-alignment-sizeof(void*);
380}
381#endif
382
383/*********************************************************************
384 * calloc (MSVCRT.@)
385 */
387{
388 size_t bytes = count*size;
389
390 if (size && bytes / size != count)
391 {
392 *_errno() = ENOMEM;
393 return NULL;
394 }
395
397}
398
399#if _MSVCR_VER>=140
400/*********************************************************************
401 * _calloc_base (UCRTBASE.@)
402 */
403void* CDECL _calloc_base(size_t count, size_t size)
404{
405 return calloc(count, size);
406}
407#endif
408
409/*********************************************************************
410 * free (MSVCRT.@)
411 */
413{
415}
416
417#if _MSVCR_VER>=140
418/*********************************************************************
419 * _free_base (UCRTBASE.@)
420 */
421void CDECL _free_base(void* ptr)
422{
424}
425#endif
426
427/*********************************************************************
428 * malloc (MSVCRT.@)
429 */
430void* CDECL malloc(size_t size)
431{
432 void *ret;
433
434 do
435 {
437 if (ret || !MSVCRT_new_mode)
438 break;
439 } while(_callnewh(size));
440
441 if (!ret)
442 *_errno() = ENOMEM;
443 return ret;
444}
445
446#if _MSVCR_VER>=140
447/*********************************************************************
448 * _malloc_base (UCRTBASE.@)
449 */
450void* CDECL _malloc_base(size_t size)
451{
452 return malloc(size);
453}
454#endif
455
456/*********************************************************************
457 * realloc (MSVCRT.@)
458 */
460{
461 if (!ptr) return malloc(size);
462 if (size) return msvcrt_heap_realloc(0, ptr, size);
463 free(ptr);
464 return NULL;
465}
466
467#if _MSVCR_VER>=140
468/*********************************************************************
469 * _realloc_base (UCRTBASE.@)
470 */
471void* CDECL _realloc_base(void* ptr, size_t size)
472{
473 return realloc(ptr, size);
474}
475#endif
476
477#if _MSVCR_VER>=80
478/*********************************************************************
479 * _recalloc (MSVCR80.@)
480 */
481void* CDECL _recalloc(void *mem, size_t num, size_t size)
482{
483 size_t old_size;
484 void *ret;
485
486 if(!mem)
487 return calloc(num, size);
488
489 size = num*size;
491
492 ret = realloc(mem, size);
493 if(!ret) {
494 *_errno() = ENOMEM;
495 return NULL;
496 }
497
498 if(size>old_size)
500 return ret;
501}
502#endif
503
504/*********************************************************************
505 * __p__amblksiz (MSVCRT.@)
506 */
507unsigned int* CDECL __p__amblksiz(void)
508{
509 return &MSVCRT_amblksiz;
510}
511
512/*********************************************************************
513 * _get_sbh_threshold (MSVCRT.@)
514 */
516{
518}
519
520/*********************************************************************
521 * _set_sbh_threshold (MSVCRT.@)
522 */
523int CDECL _set_sbh_threshold(size_t threshold)
524{
525#ifdef _WIN64
526 return 0;
527#else
528 if(threshold > 1016)
529 return 0;
530
531 if(!sb_heap)
532 {
533 sb_heap = HeapCreate(0, 0, 0);
534 if(!sb_heap)
535 return 0;
536 }
537
538 MSVCRT_sbh_threshold = (threshold+0xf) & ~0xf;
539 return 1;
540#endif
541}
542
543/*********************************************************************
544 * _aligned_free (MSVCRT.@)
545 */
546void CDECL _aligned_free(void *memblock)
547{
548 TRACE("(%p)\n", memblock);
549
550 if (memblock)
551 {
552 void **saved = SAVED_PTR(memblock);
553 free(*saved);
554 }
555}
556
557/*********************************************************************
558 * _aligned_offset_malloc (MSVCRT.@)
559 */
560void * CDECL _aligned_offset_malloc(size_t size, size_t alignment, size_t offset)
561{
562 void *memblock, *temp, **saved;
563 TRACE("(%Iu, %Iu, %Iu)\n", size, alignment, offset);
564
565 /* alignment must be a power of 2 */
566 if ((alignment & (alignment - 1)) != 0)
567 {
568 *_errno() = EINVAL;
569 return NULL;
570 }
571
572 /* offset must be less than size */
573 if (offset && offset >= size)
574 {
575 *_errno() = EINVAL;
576 return NULL;
577 }
578
579 /* don't align to less than void pointer size */
580 if (alignment < sizeof(void *))
581 alignment = sizeof(void *);
582
583 /* allocate enough space for void pointer and alignment */
584 temp = malloc(size + alignment + sizeof(void *));
585
586 if (!temp)
587 return NULL;
588
589 /* adjust pointer for proper alignment and offset */
590 memblock = ALIGN_PTR(temp, alignment, offset);
591
592 /* Save the real allocation address below returned address */
593 /* so it can be found later to free. */
594 saved = SAVED_PTR(memblock);
595 *saved = temp;
596
597 return memblock;
598}
599
600/*********************************************************************
601 * _aligned_malloc (MSVCRT.@)
602 */
603void * CDECL _aligned_malloc(size_t size, size_t alignment)
604{
605 TRACE("(%Iu, %Iu)\n", size, alignment);
607}
608
609/*********************************************************************
610 * _aligned_offset_realloc (MSVCRT.@)
611 */
612void * CDECL _aligned_offset_realloc(void *memblock, size_t size,
613 size_t alignment, size_t offset)
614{
615 void * temp, **saved;
616 size_t old_padding, new_padding, old_size;
617 TRACE("(%p, %Iu, %Iu, %Iu)\n", memblock, size, alignment, offset);
618
619 if (!memblock)
621
622 /* alignment must be a power of 2 */
623 if ((alignment & (alignment - 1)) != 0)
624 {
625 *_errno() = EINVAL;
626 return NULL;
627 }
628
629 /* offset must be less than size */
630 if (offset >= size)
631 {
632 *_errno() = EINVAL;
633 return NULL;
634 }
635
636 if (size == 0)
637 {
638 _aligned_free(memblock);
639 return NULL;
640 }
641
642 /* don't align to less than void pointer size */
643 if (alignment < sizeof(void *))
644 alignment = sizeof(void *);
645
646 /* make sure alignment and offset didn't change */
647 saved = SAVED_PTR(memblock);
648 if (memblock != ALIGN_PTR(*saved, alignment, offset))
649 {
650 *_errno() = EINVAL;
651 return NULL;
652 }
653
654 old_padding = (char *)memblock - (char *)*saved;
655
656 /* Get previous size of block */
657 old_size = _msize(*saved);
658 if (old_size == -1)
659 {
660 /* It seems this function was called with an invalid pointer. Bail out. */
661 return NULL;
662 }
663
664 /* Adjust old_size to get amount of actual data in old block. */
665 if (old_size < old_padding)
666 {
667 /* Shouldn't happen. Something's weird, so bail out. */
668 return NULL;
669 }
670 old_size -= old_padding;
671
672 temp = realloc(*saved, size + alignment + sizeof(void *));
673
674 if (!temp)
675 return NULL;
676
677 /* adjust pointer for proper alignment and offset */
678 memblock = ALIGN_PTR(temp, alignment, offset);
679
680 /* Save the real allocation address below returned address */
681 /* so it can be found later to free. */
682 saved = SAVED_PTR(memblock);
683
684 new_padding = (char *)memblock - (char *)temp;
685
686/*
687 Memory layout of old block is as follows:
688 +-------+---------------------+-+--------------------------+-----------+
689 | ... | "old_padding" bytes | | ... "old_size" bytes ... | ... |
690 +-------+---------------------+-+--------------------------+-----------+
691 ^ ^ ^
692 | | |
693 *saved saved memblock
694
695 Memory layout of new block is as follows:
696 +-------+-----------------------------+-+----------------------+-------+
697 | ... | "new_padding" bytes | | ... "size" bytes ... | ... |
698 +-------+-----------------------------+-+----------------------+-------+
699 ^ ^ ^
700 | | |
701 temp saved memblock
702
703 However, in the new block, actual data is still written as follows
704 (because it was copied by realloc):
705 +-------+---------------------+--------------------------------+-------+
706 | ... | "old_padding" bytes | ... "old_size" bytes ... | ... |
707 +-------+---------------------+--------------------------------+-------+
708 ^ ^ ^
709 | | |
710 temp saved memblock
711
712 Therefore, min(old_size,size) bytes of actual data have to be moved
713 from the offset they were at in the old block (temp + old_padding),
714 to the offset they have to be in the new block (temp + new_padding == memblock).
715*/
716 if (new_padding != old_padding)
717 memmove((char *)memblock, (char *)temp + old_padding, (old_size < size) ? old_size : size);
718
719 *saved = temp;
720
721 return memblock;
722}
723
724/*********************************************************************
725 * _aligned_realloc (MSVCRT.@)
726 */
727void * CDECL _aligned_realloc(void *memblock, size_t size, size_t alignment)
728{
729 TRACE("(%p, %Iu, %Iu)\n", memblock, size, alignment);
730 return _aligned_offset_realloc(memblock, size, alignment, 0);
731}
732
733/*********************************************************************
734 * memmove_s (MSVCRT.@)
735 */
736int CDECL memmove_s(void *dest, size_t numberOfElements, const void *src, size_t count)
737{
738 TRACE("(%p %Iu %p %Iu)\n", dest, numberOfElements, src, count);
739
740 if(!count)
741 return 0;
742
743 if (!MSVCRT_CHECK_PMT(dest != NULL)) return EINVAL;
744 if (!MSVCRT_CHECK_PMT(src != NULL)) return EINVAL;
746
748 return 0;
749}
750
751#if _MSVCR_VER>=100
752/*********************************************************************
753 * wmemmove_s (MSVCR100.@)
754 */
755int CDECL wmemmove_s(wchar_t *dest, size_t numberOfElements,
756 const wchar_t *src, size_t count)
757{
758 TRACE("(%p %Iu %p %Iu)\n", dest, numberOfElements, src, count);
759
760 if (!count)
761 return 0;
762
763 /* Native does not seem to conform to 6.7.1.2.3 in
764 * http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1225.pdf
765 * in that it does not zero the output buffer on constraint violation.
766 */
767 if (!MSVCRT_CHECK_PMT(dest != NULL)) return EINVAL;
768 if (!MSVCRT_CHECK_PMT(src != NULL)) return EINVAL;
770
771 memmove(dest, src, sizeof(wchar_t)*count);
772 return 0;
773}
774#endif
775
776/*********************************************************************
777 * memcpy_s (MSVCRT.@)
778 */
779int CDECL memcpy_s(void *dest, size_t numberOfElements, const void *src, size_t count)
780{
781 TRACE("(%p %Iu %p %Iu)\n", dest, numberOfElements, src, count);
782
783 if(!count)
784 return 0;
785
786 if (!MSVCRT_CHECK_PMT(dest != NULL)) return EINVAL;
787 if (!MSVCRT_CHECK_PMT(src != NULL))
788 {
790 return EINVAL;
791 }
793 {
795 return ERANGE;
796 }
797
799 return 0;
800}
801
802#if _MSVCR_VER>=100
803/*********************************************************************
804 * wmemcpy_s (MSVCR100.@)
805 */
806int CDECL wmemcpy_s(wchar_t *dest, size_t numberOfElements,
807 const wchar_t *src, size_t count)
808{
809 TRACE("(%p %Iu %p %Iu)\n", dest, numberOfElements, src, count);
810
811 if (!count)
812 return 0;
813
814 if (!MSVCRT_CHECK_PMT(dest != NULL)) return EINVAL;
815
816 if (!MSVCRT_CHECK_PMT(src != NULL)) {
817 memset(dest, 0, numberOfElements*sizeof(wchar_t));
818 return EINVAL;
819 }
821 memset(dest, 0, numberOfElements*sizeof(wchar_t));
822 return ERANGE;
823 }
824
825 memmove(dest, src, sizeof(wchar_t)*count);
826 return 0;
827}
828#endif
829
831{
832#if _MSVCR_VER <= 100 && !defined(__REACTOS__)
833 heap = HeapCreate(0, 0, 0);
834#else
836#endif
837 return heap != NULL;
838}
839
841{
842#if _MSVCR_VER <= 100 && !defined(__REACTOS__)
844#endif
845 if(sb_heap)
847}
#define DECLSPEC_HOTPATCH
Definition: _mingw.h:240
static unsigned char bytes[4]
Definition: adnsresfilter.c:74
_Check_return_ _Ret_maybenull_ _In_ size_t alignment
Definition: align.cpp:48
#define InterlockedExchange
Definition: armddk.h:54
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define FIXME(fmt,...)
Definition: precomp.h:53
#define WARN(fmt,...)
Definition: precomp.h:61
#define realloc
Definition: debug_ros.c:6
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#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:7512
int *CDECL _errno(void)
Definition: errno.c:215
void CDECL DECLSPEC_HOTPATCH operator_delete(void *mem)
Definition: heap.c:177
int CDECL _heapmin(void)
Definition: heap.c:258
static void * msvcrt_heap_alloc(DWORD flags, size_t size)
Definition: heap.c:56
MSVCRT_new_handler_func CDECL _query_new_handler(void)
Definition: heap.c:187
size_t CDECL _get_sbh_threshold(void)
Definition: heap.c:515
static LONG MSVCRT_new_mode
Definition: heap.c:49
static HANDLE heap
Definition: heap.c:44
void *CDECL _aligned_offset_malloc(size_t size, size_t alignment, size_t offset)
Definition: heap.c:560
int CDECL memmove_s(void *dest, size_t numberOfElements, const void *src, size_t count)
Definition: heap.c:736
BOOL msvcrt_init_heap(void)
Definition: heap.c:830
MSVCRT_new_handler_func CDECL set_new_handler(void *func)
Definition: heap.c:217
int CDECL memcpy_s(void *dest, size_t numberOfElements, const void *src, size_t count)
Definition: heap.c:779
#define SB_HEAP_ALIGN
Definition: heap.c:42
int CDECL _heapchk(void)
Definition: heap.c:244
static size_t MSVCRT_sbh_threshold
Definition: heap.c:54
int CDECL _heapset(unsigned int value)
Definition: heap.c:317
void msvcrt_destroy_heap(void)
Definition: heap.c:840
static size_t msvcrt_heap_size(void *ptr)
Definition: heap.c:117
#define UNLOCK_HEAP
Definition: heap.c:33
#define SAVED_PTR(x)
Definition: heap.c:36
void *CDECL DECLSPEC_HOTPATCH operator_new(size_t size)
Definition: heap.c:143
void *CDECL _aligned_offset_realloc(void *memblock, size_t size, size_t alignment, size_t offset)
Definition: heap.c:612
int CDECL _query_new_mode(void)
Definition: heap.c:196
unsigned int *CDECL __p__amblksiz(void)
Definition: heap.c:507
int CDECL _set_new_mode(int mode)
Definition: heap.c:227
MSVCRT_new_handler_func CDECL _set_new_handler(MSVCRT_new_handler_func func)
Definition: heap.c:204
static HANDLE sb_heap
Definition: heap.c:44
void *CDECL _aligned_malloc(size_t size, size_t alignment)
Definition: heap.c:603
void *CDECL _expand(void *mem, size_t size)
Definition: heap.c:236
int(CDECL * MSVCRT_new_handler_func)(size_t size)
Definition: heap.c:46
static unsigned int MSVCRT_amblksiz
Definition: heap.c:52
static MSVCRT_new_handler_func MSVCRT_new_handler
Definition: heap.c:48
#define ALIGN_PTR(ptr, alignment, offset)
Definition: heap.c:38
void CDECL _aligned_free(void *memblock)
Definition: heap.c:546
int CDECL _heapadd(void *mem, size_t size)
Definition: heap.c:336
void *CDECL _aligned_realloc(void *memblock, size_t size, size_t alignment)
Definition: heap.c:727
static void * msvcrt_heap_realloc(DWORD flags, void *ptr, size_t size)
Definition: heap.c:74
int CDECL _callnewh(size_t size)
Definition: heap.c:131
size_t CDECL _msize(void *mem)
Definition: heap.c:354
intptr_t CDECL _get_heap_handle(void)
Definition: heap.c:346
static BOOL msvcrt_heap_free(void *ptr)
Definition: heap.c:106
int CDECL _set_sbh_threshold(size_t threshold)
Definition: heap.c:523
void *CDECL operator_new_dbg(size_t size, int type, const char *file, int line)
Definition: heap.c:168
int CDECL _heapwalk(_HEAPINFO *next)
Definition: heap.c:273
#define LOCK_HEAP
Definition: heap.c:32
int intptr_t
Definition: corecrt.h:176
_ACRTIMP void *__cdecl _recalloc(void *, size_t, size_t) __WINE_ALLOC_SIZE(2
#define EINVAL
Definition: errno.h:44
#define ENOSYS
Definition: errno.h:60
#define ENOMEM
Definition: errno.h:35
#define ERANGE
Definition: errno.h:55
#define _HEAPOK
Definition: malloc.h:28
#define _HEAPBADBEGIN
Definition: malloc.h:29
#define _HEAPBADNODE
Definition: malloc.h:30
#define _HEAPEND
Definition: malloc.h:31
#define _FREEENTRY
Definition: malloc.h:34
#define _USEDENTRY
Definition: malloc.h:35
_ACRTIMP errno_t __cdecl wmemcpy_s(wchar_t *, size_t, const wchar_t *, size_t)
Definition: wmemcpy_s.cpp:18
#define MSVCRT_CHECK_PMT(x)
Definition: msvcrt.h:378
#define MSVCRT_CHECK_PMT_ERR(x, err)
Definition: msvcrt.h:377
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
return ret
Definition: mutex.c:146
size_t const old_size
Definition: expand.cpp:65
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLenum func
Definition: glext.h:6028
GLenum src
Definition: glext.h:6340
GLsizeiptr size
Definition: glext.h:5919
GLintptr offset
Definition: glext.h:5920
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
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
#define PROCESS_HEAP_UNCOMMITTED_RANGE
Definition: minwinbase.h:76
#define PROCESS_HEAP_ENTRY_BUSY
Definition: minwinbase.h:77
#define PROCESS_HEAP_REGION
Definition: minwinbase.h:75
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
static PVOID ptr
Definition: dispmode.c:27
static size_t numberOfElements
Definition: string.c:98
static char * dest
Definition: rtl.c:135
#define HEAP_REALLOC_IN_PLACE_ONLY
Definition: nt_native.h:1699
long LONG
Definition: pedump.c:60
static unsigned __int64 next
Definition: rand_nt.c:6
#define calloc
Definition: rosglue.h:14
static calc_node_t temp
Definition: rpn_ieee.c:38
_Check_return_ _ACRTIMP size_t __cdecl _aligned_msize(_Pre_notnull_ void *_Block, _In_ size_t _Alignment, _In_ size_t _Offset)
_ACRTIMP void __cdecl _free_base(_Pre_maybenull_ _Post_invalid_ void *_Block)
#define msvcrt_set_errno
Definition: heap.c:50
#define memset(x, y, z)
Definition: compat.h:39
#define TRACE(s)
Definition: solgame.cpp:4
Definition: minwinbase.h:361
WORD wFlags
Definition: minwinbase.h:366
PVOID lpData
Definition: minwinbase.h:362
DWORD cbData
Definition: minwinbase.h:363
Definition: fci.c:127
Definition: parser.c:49
Definition: mem.c:349
Definition: pdh_main.c:96
int retval
Definition: wcstombs.cpp:91
SIZE_T WINAPI HeapSize(HANDLE, DWORD, LPCVOID)
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
errno_t __cdecl wmemmove_s(wchar_t *const destination, size_t const size_in_elements, wchar_t const *const source, size_t const count)
Definition: wmemmove_s.cpp:17
unsigned char BYTE
Definition: xxhash.c:193