Espacios de nombres
Variantes
Acciones

realloc

De cppreference.com
< c‎ | memory

Defined in header <stdlib.h>
void *realloc( void *ptr, size_t new_size );
Reasigna el área concreta de memoria. Debe ser asignado con anterioridad por malloc(), calloc() o realloc() y aún no liberado con free(), de lo contrario, los resultados son 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.
La reasignación se lleva a cabo mediante:
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)
la expansión del área existente a la que apunta ptr, si es posible. El contenido de la zona permanecen sin cambios hasta el menor de los tamaños nuevos y viejos. Si el área se expande, el contenido de la parte nueva de la matriz son 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)
la asignación de un nuevo bloque de memoria de bytes new_size tamaño, copiar área de memoria con un tamaño igual al menor de los nuevos y los viejos tamaños y liberar el bloque antiguo .
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.
Si no hay memoria suficiente, el bloque de memoria de edad no se libera y puntero nulo se devuelve .
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.

Contenido

[editar] Parámetros

ptr -
puntero al área de memoria para ser reasignados
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 -
nuevo tamaño de la 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

Puntero al principio de la memoria recién asignada o NULL si el error se ha producido. El puntero se debe desasignar con 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] Ejemplo

[editar] Ver también

C++ documentation for realloc