blob: 240baa6e26819b35a42285fc43fa4656c826e428 [file] [log] [blame]
Jeff Thompson10ad12a2013-09-24 16:19:11 -07001/**
2 * Copyright (C) 2013 Regents of the University of California.
3 * @author: Jeff Thompson <jefft0@remap.ucla.edu>
4 * See COPYING for copyright and distribution information.
5 */
6
7#include "dynamic-uint8-vector.hpp"
8
9using namespace std;
10
11namespace ndn {
12
13DynamicUInt8Vector::DynamicUInt8Vector(unsigned int initialLength)
14: vector_(new vector<uint8_t>(initialLength))
15{
16 ndn_DynamicUInt8Array_initialize(this, &vector_->front(), initialLength, DynamicUInt8Vector::realloc);
17}
18
19uint8_t*
20DynamicUInt8Vector::realloc(struct ndn_DynamicUInt8Array *self, uint8_t *array, unsigned int length)
21{
22 // Because this method is private, assume there is not a problem with upcasting.
23 DynamicUInt8Vector *thisObject = (DynamicUInt8Vector *)self;
24
25 if (array != &thisObject->vector_->front())
26 // We don't expect this to ever happen. The caller didn't pass the array from this object.
27 return 0;
28
29 thisObject->vector_->resize(length);
30 return &thisObject->vector_->front();
31}
32
33}