About 12,800,000 results
Open links in new tab
  1. When and why to use malloc - Stack Overflow

    55 You use malloc when you need to allocate objects that must exist beyond the lifetime of execution of the current block (where a copy-on-return would be expensive as well), or if you …

  2. C Programming: malloc() inside another function - Stack Overflow

    I need help with malloc() inside another function. I'm passing a pointer and size to the function from my main() and I would like to allocate memory for that pointer dynamically using malloc() …

  3. 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* …

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

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

  5. 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.

  6. 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 …

  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 …

  8. In what cases do I use malloc and/or new? - Stack Overflow

    I see in C++ there are multiple ways to allocate and free data and I understand that when you call malloc you should call free and when you use the new operator you should pair with delete …

  9. crash - How to troubleshoot crashes in malloc - Stack Overflow

    malloc stores a small header of information "in front of" the memory block that it returns to you. This information usually contains the size of the block and a pointer to the next block.

  10. c - What if malloc fails? - Stack Overflow

    May 28, 2015 · In general, a modern malloc() implementation will return NULL only as an absolute last resort, and trying again will definitely not help. The only thing that will help is freeing some …