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

sqlite3_malloc(), sqlite3_free()