Name
sqlite3_realloc() — Resize a dynamic memory allocation
Definition
void* sqlite3_realloc( void* ptr, int bytes );
-
ptr A pointer to an existing dynamic memory buffer. May be NULL.
-
bytes The new size of the requested buffer, in bytes.
- Returns
The newly adjusted buffer. May be NULL if unable to allocate memory. If NULL, the old buffer will still be valid.
Description
This function resizes a dynamic memory allocation. It can be used to increase or decrease the size of an allocation. This may require moving the allocation. In that case, the contents of the current buffer will be copied to the beginning of the adjusted buffer. If the new buffer is smaller, some data will be dropped. Allocations will always start on an 8-byte (or larger) boundary.
If a NULL pointer is passed in, this function will act like
sqlite3_malloc() and
allocate a new buffer. If the bytes parameter is zero or
negative, this function will act like sqlite3_free(), releasing the existing buffer
and returning NULL.
See Also
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access