Top "Malloc" questions

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

Can you allocate a very large single chunk of memory ( > 4GB ) in c or c++?

With very large amounts of ram these days I was wondering, it is possible to allocate a single chunk of …

c++ c memory malloc
Should I check if malloc() was successful?

Should one check after each malloc() if it was successful? Is it at all possible that a malloc() fails? What …

c error-handling malloc runtime-error allocation
Xcode Guard Malloc and on Device Debugging: 'libgmalloc.dylib' image not found

I enabled memory checking in Xcode (Edit Scheme -> Options). I'm now getting the following when I perform on …

xcode malloc
Malloc and Void Pointers

I'm studying this malloc function and I could use some help: static void *malloc(int size) { void *p; if (size &…

c malloc void-pointers
Linked Lists in C without malloc

#include <stdio.h> typedef struct node { int i; struct node *next; }node; node getnode(int a) { struct node …

c malloc linked-list
malloc behaviour on an embedded system

I'm currently working on an embedded project (STM32F103RB, CooCox CoIDE v.1.7.6 with arm-none-eabi-gcc 4.8 2013q4) and I'm trying to …

c memory-management malloc out-of-memory stm32
Can I assume that calling realloc with a smaller size will free the remainder?

Let’s consider this very short snippet of code: #include <stdlib.h> int main() { char* a = malloc(20000); char* …

c malloc free realloc
invalid application of 'sizeof' to incomplete type list struct C

I'm trying to implement an replacement algorithm that deals with page faults. So i'm trying to creat a circular linked …

c list malloc circular-list
How to run valgrind with basic c example?

Installation: bzip2 -d valgrind-3.10.1.tar.bz2 tar -xf valgrind-3.10.1.tar then: ./configure make make install or simplier sudo apt-get install …

c++ c memory-leaks malloc valgrind
Specifically, how does fork() handle dynamically allocated memory from malloc() in Linux?

I have a program with a parent and a child process. Before the fork(), the parent process called malloc() and …

c linux malloc heap fork