About 67 results
Open links in new tab
  1. c - Proper usage of realloc () - Stack Overflow

    From man realloc:The realloc() function returns a pointer to the newly allocated memory, which is suitably aligned for any kind of variable and may be different from ptr, or NULL if the request

  2. arrays - How to use realloc in a function in C - Stack Overflow

    Dec 7, 2012 · Both code are very problematic, if you use the same pointer to send and receive from realloc, if it fails, you will lose your pointer to free it later. you should do some thing like this :

  3. c - How does realloc () work? - Stack Overflow

    realloc might return 0. old is not touched if the block pointed to by old is >= size, realloc might return old alternatively realloc allocates a block >= size, copies all bytes from old up to size, frees old and …

  4. Manipulação do malloc () e realloc () - Stack Overflow em Português

    Aug 14, 2018 · O realloc() é um malloc() que muda o tamanho alocado anteriormente. Um bom algoritmo tenta aumentar seu tamanho sem mudar a sua localização, mas nem sempre é possível, …

  5. c - How does realloc () reallocate the memory? - Stack Overflow

    Jan 14, 2020 · How does realloc() reallocate the memory which was first allocated by malloc()? I know that you need to use malloc() before you´re able to reallocate the memory, but I don´t understand …

  6. c - Difference between malloc and realloc? - Stack Overflow

    When NULL is passed, realloc is equivalent to malloc. The NULL call can be useful if you're re allocating in some kind of loop and don't want to have a special case the first time you allocate.

  7. c - resizing an existing array using `realloc` - Stack Overflow

    Jul 14, 2022 · I defined an array and I tried to resize using realloc() but it is not working. My question is can I do that using arr[] or do I have to use calloc() or malloc() first to define the array and then ...

  8. Using realloc to shrink the allocated memory - Stack Overflow

    Aug 16, 2011 · There is definitely not a memory leak, but any of at least 3 things could happen when you call realloc to reduce the size: The implementation splits the allocated memory block at the new …

  9. c - Is it safe to use realloc? - Stack Overflow

    7 realloc is safe in itself, but using it safely is a bit tricky -- to the point that I'd say roughly 85-90% of the code I've seen that uses it does not do so safely. The problem is that realloc returns NULL to indicate …

  10. How is realloc implemented in the C standard library?

    Aug 11, 2019 · In the last line, rax contains the pointer to the new memory region (returned by realloc) which is assigned to the pointer ptr (notice, rbp-0x8 is the location of the pointer on the stack). How is …