How can I access heap memory next to using malloc?

Is there a way that you can assign memory from a heap without calling malloc? Could this call be affective for him?

void* loc = (void*) &heap[end_of_heap];
+3
source share
5 answers

No. The C language itself does not provide such functions. If you do not care what Unix systems comply with outdated features of the old version of the Unix standard (SUSv2 or earlier, if I remember correctly), the functions brkand sbrkprovide this function. But you really shouldn't use it unless you write very low-level code that you never need to port.

+7
source

malloc , sbrk ( brk) Unix ( Posix), . manpage

brk() sbrk(): malloc (3)         .

, , ( , ). mmap /dev/ Unix, Windows " API Win32" ..

+6

, . .

+3

( , ). ( ).

: C. , , API- . , OS API .

+2

malloc, .

, , bget memory allocator. ( , + ), malloc bget bpool. bget malloc, brel, . bget .

+2

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


All Articles