Allocating memory to Windows C code

I would like to know which method is recommended for programming in Windows C: using the malloc or Win32 HeapAlloc function (perhaps VirtualAlloc?).

I read the MSDN article Memory Management Functions and the MSDN articles regarding malloc and HeapAlloc, but they do not say what to use and in what situations.

+3
source share
7 answers

Stick to malloc unless you have a good reason to use something else. It will be implemented under the primitives of OS memory allocation, but there is no real advantage in immersing yourself in this level.

API, , , , Windows, , .

, - , , , Windows API, VirtualAlloc.

+18

VirtualAlloc , , .

, , malloc().

VirtualAlloc MEM_RESET, , . , , Windows , . , , , - , .

. , .

+4

: malloc() ( , ANSI-C) .

+3

, , HeapAlloc, HeapFree . : , ( library1.dll) (, program.exe). , HeapAlloc, HeapResize HeapFree, C (, malloc, free, resize).

: , malloc/free/resize. , (: , ..), , VirtualAlloc, VirtualFree.

+2

. , .

+1

Rob, ... WinAPI, C-run-time, .

0

HeapAlloc /. .

malloc , , CRT OS HeapAlloc.

VirtualAlloc , ( Heap *).

0
source

Source: https://habr.com/ru/post/1698811/


All Articles