Top "Malloc" questions

The malloc function performs dynamic memory allocation in C and is part of the standard library.

What is a Memory Heap?

What is a memory heap ?

malloc
How is malloc() implemented internally?

Can anyone explain how malloc() works internally? I have sometimes done strace program and I see a lot of sbrk …

c memory malloc system-calls sbrk
Why do I get a C malloc assertion failure?

I am implementing a divide and conquer polynomial algorithm so I can benchmark it against an OpenCL implementation, but I …

c gcc malloc assertion
What REALLY happens when you don't free after malloc?

This has been something that has bothered me for ages now. We are all taught in school (at least, I …

c malloc free
C - freeing structs

Let's say I have this struct typedef struct person{ char firstName[100], surName[51] } PERSON; and I am allocating space by malloc …

c struct malloc
Why do I get a warning every time I use malloc?

If I use malloc in my code: int *x = malloc(sizeof(int)); I get this warning from gcc: new.c:7: …

c gcc malloc warnings sizeof
How do I free memory in C?

I'm writing code which has a lot of 1 & 2 dimensional arrays. I got "error: can't allocate region" and I think …

c memory-management malloc
invalid conversion from `void*' to `char*' when using malloc?

I'm having trouble with the code below with the error on line 5: error: invalid conversion from void* to char* I'm …

c++ g++ malloc
Setting variable to NULL after free

In my company there is a coding rule that says, after freeing any memory, reset the variable to NULL. For …

c coding-style malloc free heap-memory
C Programming: malloc() inside another function

I need help with malloc() inside another function. I'm passing a pointer and size to the function from my main() …

c function pointers malloc