Top "Malloc" questions

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

What happens to memory after '\0' in a C string?

Surprisingly simple/stupid/basic question, but I have no idea: Suppose I want to return the user of my function …

c string pointers malloc c-strings
When to free memory inside a C code?

When I alloc memory outside a while loop for example, is it okay to free it inside it ? Are these …

c memory malloc calloc
Why exactly should I not call free() on variables not allocated by malloc()?

I read somewhere that it is disastrous to use free to get rid of an object not created by calling …

c memory memory-management free malloc
(XCode 7 + iOS 9 + iPhone 4s/iPhone5 only) issue: "malloc: *** mach_vm_map(size=1048576) failed (error code=3)"

I know the issue is related to memory allocations, but I get it in only iOS 9, XCode 7. In XCode 6.4, iOS 8.4, …

malloc ios9 xcode7 xcode6.4 ios8.4
Link list program to Display Student marks

#include<stdio.h> #include<conio.h> #include<stdlib.h> void Insert(); void DisplayList(); struct …

c linked-list malloc displaylist httpunhandledexception
C API design: Who should allocate?

What is the proper/preferred way to allocate memory in a C API? I can see, at first, two options: 1) …

c api memory-management malloc
Why does `free` in C not take the number of bytes to be freed?

Just to be clear: I do know that malloc and free are implemented in the C library, which usually allocates …

c memory-management malloc free
realloc invalid old size

Disclaimer: This is homework. I am attempting it and do not expect or want anyone to do it for me. …

c pointers malloc realloc
Is it better to allocate memory in the power of two?

When we use malloc() to allocate memory, should we give the size which is in power of two? Or we …

c memory-management malloc
malloc and pointers to pointers

I'm trying to understand when I need to use malloc when using multiple levels of pointers. For example, #include <…

c pointers malloc pointer-to-pointer