AP_realloc

Reallocate an outgoing message buffer

Synopsis

#include "autopack.h"

void *AP_realloc(void *buf, int newsize)

Parameters

buf
an outgoing buffer previously allocated by AP_alloc()
newsize
the new desired size of the buffer

Description

Still being tested.

Changes the size of the buffer pointed to by buf to newsize bytes and returns a pointer to the (possibly moved) buffer. The contents will be unchanged up to the lesser of the new and old sizes.

The buffer must be the most recently allocated buffer for the destination, otherwise it is an error. It is also erroneous to specify a buffer which has previously passed to AP_send(). These errors may or may not be detected depending on whether the library was compiled with NO_USER_CHECKS.

If the buffer is reduced in size, it is guaranteed not to be moved. If the buffer is increased in size, it may or may not move depending on available space in the current internal memory block (package).

Return Value

A pointer to the reallocated buffer.