Top "Malloc" questions

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

glibc detected, realloc(): invalid pointer

I apologize for the lengthy code. I have a simple question, but I thought I include my code so it …

c malloc free glibc realloc
Uninitialised value was created by a heap allocation

I have been chasing this bug around, and I just don't get it. Have I forgotten some basic C or …

c pointers malloc valgrind strncpy
What is the limit on malloc parameter of type size_t in C? Docs say it has an upper limit of UINT_MAX but I can't go beyond INT_MAX

I want to allocate a 2.9GB char array with database = (char*) malloc((2900 * 1000000 * sizeof(char))); This gives an integer overflow warning …

c malloc limit size-t
How bad it is to keep calling malloc() and free()?

I'm sending a text file - client-server breakup the text into packets each of 512 bytes but some packets contain text …

c network-programming malloc free packets
Does malloc() use brk() or mmap()?

c code: // program break mechanism // TLPI exercise 7-1 #include <stdio.h> #include <stdlib.h> void program_…

c memory-management malloc mmap sbrk
SIGABRT in malloc.c, what just happened?

I wrote this innocent piece of code, and results in such an evil error: static char * prefixed( char * pref, char *…

c malloc runtime-error sigabrt cgdb
What if I allocate memory using mmap instead of malloc?

What are the disadvantages of allocating memory using mmap (with MAP_PRIVATE and MAP_ANONYMOUS) than using malloc? For data …

c linux memory-management malloc mmap
Multithreaded Memory Allocators for C/C++

I currently have heavily multi-threaded server application, and I'm shopping around for a good multi-threaded memory allocator. So far I'm …

c++ c memory malloc allocation
Can I allocate a specific number of bits in C?

I am trying to store a large amount of boolean information that is determined at run-time. I was wondering what …

c malloc bitmask
An alternative for the deprecated __malloc_hook functionality of glibc

I am writing a memory profiler for C and for that am intercepting calls to the malloc, realloc and free …

c gcc malloc deprecated glibc