Espaços nominais
Variantes
Acções

realloc

Da cppreference.com
< c‎ | memory

Definido no cabeçalho <stdlib.h>
void *realloc( void *ptr, size_t new_size );
Realoca a determinada área de memória. Deve ser previamente alocado pelo malloc(), calloc() ou realloc() e ainda não liberado com free(), caso contrário, os resultados são indefinidos.
Original:
Reallocates the given area of memory. It must be previously allocated by malloc(), calloc() or realloc() and not yet freed with free(), otherwise, the results are undefined.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
A redistribuição é feita por meio de:
Original:
The reallocation is done by either:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
a)
expandir a área existente apontado por ptr, se possível. O conteúdo da zona permanecem inalteradas até ao menor dos tamanhos novos e velhos. Se a zona for expandido, o conteúdo da nova parte da matriz são indefinidos.
Original:
expanding the existing area pointed to by ptr, if possible. The contents of the area remain unchanged up to the lesser of the new and old sizes. If the area is expanded, the contents of the new part of the array are undefined.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
b)
atribuição de um novo bloco de memória de bytes new_size tamanho, cópia área de memória com tamanho igual a menor da nova e os tamanhos de idade, e libertar o antigo bloco.
Original:
allocating a new memory block of size new_size bytes, copying memory area with size equal the lesser of the new and the old sizes, and freeing the old block.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Se não houver memória suficiente, o bloco de memória de idade não é liberada e ponteiro nulo é devolvido.
Original:
If there is not enough memory, the old memory block is not freed and null-pointer is returned.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Índice

[editar] Parâmetros

ptr -
ponteiro para a área de memória para ser realocado
Original:
pointer to the memory area to be reallocated
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
new_size -
novo tamanho da matriz
Original:
new size of the array
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[editar] Valor de retorno

Ponteiro para o início da memória recém-alocado ou NULL se o erro ocorreu. O ponteiro deve ser desalocado com free().
Original:
Pointer to the beginning of newly allocated memory or NULL if error has occurred. The pointer must be deallocated with free().
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[editar] Exemplo

[editar] Veja também

C++ documentation for realloc