About 59 results
Open links in new tab
  1. c - When and why to use malloc - Stack Overflow

    Size malloc allows you to allocate much larger memory spaces than the one allocated simply using student p; or int x[n];. The reason being malloc allocates the space on heap while the other allocates …

  2. c++ - How do malloc () and free () work? - Stack Overflow

    Jul 13, 2009 · calloc (3) and malloc (3) do interact with the kernel to get memory, if necessary. But most implementations of free (3) do not return memory to the kernel 1, they just add it to a free list that …

  3. Uso de Malloc en C - Stack Overflow en español

    Feb 10, 2022 · Soy nueva en esto y no me queda claro cuándo debo usar malloc y cuándo no es necesario. Estoy siguiendo un curso online y en algunos ejercicios pide que "de usar malloc, …

  4. c - Difference between malloc and calloc? - Stack Overflow

    Oct 8, 2009 · malloc() and calloc() are functions from the C standard library that allow dynamic memory allocation, meaning that they both allow memory allocation during runtime.

  5. c - How malloc works? - Stack Overflow

    Possible Duplicate: How do free and malloc work in C? Consider a scenario where i have to allocate some 20 bytes of memory through malloc. For the function call to malloc() to be successful, sh...

  6. c - What happens when you call free () with a pointer to the middle of ...

    The first 4 contains the amount of data you requested (10) and then the return value of the malloc is a pointer to the first byte of unused data in the 14 allocated. When you call free on this pointer, the …

  7. When should I use malloc in C and when don't I? - Stack Overflow

    For that exact example, malloc is of little use. The primary reason malloc is needed is when you have data that must have a lifetime that is different from code scope. Your code calls malloc in one …

  8. malloc for struct and pointer in C - Stack Overflow

    First malloc allocates memory for struct, including memory for x (pointer to double). Second malloc allocates memory for double value wtich x points to.

  9. alloc, malloc, and alloca — What's the difference?

    Sep 21, 2015 · The Microsoft Visual C++ runtime includes an Alloc() function which is somewhat similar to malloc(), but this is also not part of the C standard. malloc() allocates memory on the process …

  10. How to correctly use malloc and free memory? - Stack Overflow

    Jul 4, 2014 · I am wondering what is the right/standard way to use malloc and free. Is it needed to set pointer NULL after free? Basically, which of the two following ways is correct? double* myPtr = …