std::realloc
Aus cppreference.com
![]() |
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
definiert in Header <cstdlib>
|
||
void *realloc( void *ptr, std::size_t new_size ); |
||
Verteilt den gegebenen Bereich des Speichers. Es muss zuvor durch
malloc()
zugeordnet werden, oder calloc()
realloc()
und noch nicht mit free()
befreit, andernfalls sind die Ergebnisse undefiniert .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.
You can help to correct and verify the translation. Click here for instructions.
Die Umverteilung wird entweder durch getan:
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.
You can help to correct and verify the translation. Click here for instructions.
a)
Erweiterung der bestehenden Fläche, auf die
ptr
, wenn möglich. Die Inhalte des Bereichs bleiben unverändert bis zu der kleineren der neuen und alten Größen. Wenn der Bereich erweitert wird, sind die Inhalte des neuen Teils des Arrays spezifiziert . 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.
You can help to correct and verify the translation. Click here for instructions.
b)
Vergabe einer neuen Speicherblock der Größe
new_size
bytes, Kopieren Speicherbereich mit Größe gleich der geringere der neuen und alten Größen und befreien den alten Block .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.
You can help to correct and verify the translation. Click here for instructions.
Wenn es nicht genügend Speicher, wird die alte Speicherblock nicht freigegeben und Null-Pointer zurückgegeben .
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.
You can help to correct and verify the translation. Click here for instructions.
Inhaltsverzeichnis |
[Bearbeiten] Parameter
ptr | - | Zeiger auf den Speicherbereich neu zugeteilt werden
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 | - | neue Größe des Arrays
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. |
[Bearbeiten] Rückgabewert
Zeiger auf den Beginn des neu zugewiesenen Speicher oder NULL, wenn Fehler aufgetreten ist. Der Zeiger muss mit
free()
freigegeben werden .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.
You can help to correct and verify the translation. Click here for instructions.
[Bearbeiten] Beispiel
This section is incomplete Reason: no example |
[Bearbeiten] Siehe auch
C documentation for realloc
|