Top "Malloc" questions

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

Does malloc() allocate a contiguous block of memory?

I have a piece of code written by a very old school programmer :-) . it goes something like this typedef …

c coding-style malloc
What does malloc(0) return?

What does malloc(0) return? Would the answer be same for realloc(malloc(0),0)? #include<stdio.h> #include<malloc.…

c linux pointers malloc realloc
Do I have to call memset after I allocated new memory using malloc

#include "stdlib.h" #include "stdio.h" #include "string.h" int main(int argc, char* argv[]) { int *test = malloc(15 * sizeof(int)); …

c malloc memset
zero size malloc

Very simple question, I made the following program : #include <stdlib.h> int main(int argc, char ** argv) { void * …

c malloc
What are the differences between (and reasons to choose) tcmalloc/jemalloc and memory pools?

tcmalloc/jemalloc are improved memory allocators, and memory pool is also introduced for better memory allocation. So what are the …

c linux memory malloc tcmalloc
Read binary file, save in buffer, print out content of buffer

I have a big problem that need's to be solved before I can continue with my program. I have to …

c malloc buffer binaryfiles fread
How to properly use scandir() in c?

I am trying to store list of files in a char** variable. scandir() finishes properly but I get a segmentation …

c linux string malloc scandir
Multidimensional arrays allocated through calloc

I have a question about how memory is allocated when I calloc. I had a look at this question, but …

c malloc calloc
MIPS - How does MIPS allocate memory for arrays in the stack?

I'm quite new to the MIPS assembly language and am currently taking a class on computer architecture which has a …

assembly malloc mips computer-architecture
How big can a malloc be in C?

I have a malloc in C that is 26901^2*sizeof(double) This got me thinking what the largest value can be …

c macros malloc totalview