Top "Realloc" questions

C library function for reallocating a dynamically allocated memory region.

Malloc of arrays and structs within a struct

How does one malloc a struct which is inside another struct? I would also like to malloc an array of …

c struct malloc realloc
Realloc on NULL-valued (or undefined) pointer

I was reading about realloc and got confused about a point mentioned there. Consider the code below: #include <stdio.…

c undefined-behavior realloc
Can I assume that calling realloc with a smaller size will free the remainder?

Let’s consider this very short snippet of code: #include <stdlib.h> int main() { char* a = malloc(20000); char* …

c malloc free realloc
Do we lose data in a buffer after realloc'ing?

I'm having troubles understanding how realloc works. If I malloc'ed a buffer and copied data to that buffer, let's say "…

c memory-management realloc
How do realloc and memcpy work?

I have two questions. Do realloc() and memcpy() copy the entries in an array to another in a way faster …

c memory-management realloc
Aligned memory management?

I have a few related questions about managing aligned memory blocks. Cross-platform answers would be ideal. However, as I'm pretty …

c memory-management malloc alignment realloc
How to create extensible dynamic array in Java without using pre-made classes?

Yeah, it's a homework question, so givemetehkodezplsthx! :) Anyway, here's what I need to do: I need to have a class …

java dynamic arrays realloc
Proper usage of realloc()

From man realloc:The realloc() function returns a pointer to the newly allocated memory, which is suitably aligned for any …

c memory-leaks dynamic-memory-allocation realloc calloc
realloc() invalid old size

I am doing an exercise for fun from KandR C programming book. The program is for finding the longest line …

c dynamic-memory-allocation realloc
Using Realloc in C

Its really a post for some advice in terms of the use of realloc, more specifically, if I could make …

c memory dynamic realloc