About 59 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. memory - Using Realloc in C - Stack Overflow

    Jul 3, 2013 · Its really a post for some advice in terms of the use of realloc, more specifically, if I could make use of it to simplify my existing code. Essentially, what the below does, it dynamically allocat...

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

    Aug 16, 2011 · Simple question about the realloc function in C: If I use realloc to shrink the memory block that a pointer is pointing to, does the "extra" memory get freed? Or does it need to be freed …

  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

    11 C requires that the pointer passed to realloc must be a pointer obtained from malloc, calloc or realloc function call (or a null pointer).

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

  8. Differences between using realloc vs. free -> malloc functions

    Why would one use realloc() function to resize an dynamically allocated array rather than using free() function before calling the malloc() function again (i.e. pros and cons, advantages vs.

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

    Jul 14, 2022 · realloc can only be used to resize things allocated by malloc, calloc, realloc and similar functions. Also, if realloc increases the size of the allocated object, the extra portion from the old size …

  10. new operator - How do you 'realloc' in C++? - Stack Overflow

    Aug 14, 2010 · If you want to do resizeable buffers the C way, use malloc / free / realloc, which are available in C++. If you want to do resizeable buffers the C++ way, use a vector (or deque, if you …