blob: 83016ce9b6244ee149cd1bf955bcde18c299c8bf [file] [log] [blame]
/*
* Author: Jeff Thompson
*
* BSD license, See the LICENSE file for more information.
*/
#include "DynamicUCharArray.h"
char *ndn_DynamicUCharArray_reallocArray(struct ndn_DynamicUCharArray *self, unsigned int length)
{
if (!self->realloc)
return "ndn_DynamicUCharArray_reallocArray: realloc function pointer not supplied";
// See if double is enough.
unsigned int newLength = self->length * 2;
if (length > newLength)
// The needed length is much greater, so use it.
newLength = length;
unsigned char *newArray = (*self->realloc)(self->array, newLength);
if (!newArray)
return "ndn_DynamicUCharArray_reallocArray: realloc failed";
self->array = newArray;
self->length = newLength;
return 0;
}