You don’t have to track it by your self!
size_t malloc_usable_size (void *ptr);
But it returns the real size of the allocated memory block!
Not the size you passed to malloc!
More Related Contents:
- What REALLY happens when you don’t free after malloc before program termination?
- How do I correctly set up, access, and free a multidimensional array in C?
- Why is the use of alloca() not considered good practice?
- Why malloc+memset is slower than calloc?
- C Programming: malloc() inside another function
- How do free and malloc work in C?
- Setting variable to NULL after free
- Difference between array type and array allocated with malloc
- Is malloc thread-safe?
- Create a wrapper function for malloc and free in C
- Writing to pointer out of bounds after malloc() not causing error
- What does malloc(0) return? [duplicate]
- Why do I get a C malloc assertion failure?
- C – allocating a matrix in a function
- Why do we cast return value of malloc? [duplicate]
- Explain this implementation of malloc from the K&R book
- Why, or when, do you need to dynamically allocate memory in C?
- Find malloc() array length in C? [duplicate]
- Should I check if malloc() was successful?
- How to determine the size of an allocated C buffer? [duplicate]
- Why do you specify the size when using malloc in C?
- difference between and
- C: Correctly freeing memory of a multi-dimensional array
- An alternative for the deprecated __malloc_hook functionality of glibc
- Heap allocate a 2D array (not array of pointers)
- Is freeing allocated memory needed when exiting a program in C
- C – freeing structs
- Malloc function (dynamic memory allocation) resulting in an error when it is used globally
- Why does malloc allocate a different number of bytes than requested?
- Variable Sized Arrays vs calloc in C