static LWMsgStatus realloc_wrap( LWMsgBuffer* buffer, size_t count ) { LWMsgStatus status = LWMSG_STATUS_SUCCESS; const LWMsgContext* context = buffer->data; size_t offset = buffer->cursor - buffer->base; size_t length = buffer->end - buffer->base; size_t new_length = 0; unsigned char* new_buffer = NULL; if (count) { if (length == 0) { new_length = 256; } else { new_length = length * 2; } BAIL_ON_ERROR(status = lwmsg_context_realloc( context, buffer->base, length, new_length, (void**) (void*) &new_buffer)); buffer->base = new_buffer; buffer->end = new_buffer + new_length; buffer->cursor = new_buffer + offset; } error: return status; }
static inline LWMsgStatus lwmsg_object_realloc( LWMsgDataContext* context, unsigned char* object, size_t old_size, size_t new_size, unsigned char** out ) { LWMsgStatus status = LWMSG_STATUS_SUCCESS; BAIL_ON_ERROR(status = lwmsg_context_realloc( context->context, (void*) object, old_size, new_size, (void**) (void*) out)); error: return status; }