blob: ae1b621b15053cfbe7c0d67a902c4b8cc1c2b969 [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
Jeff Thompson97223af2013-09-24 17:01:27 -070013DynamicUInt8Vector::DynamicUInt8Vector(size_t initialLength)
Jeff Thompson10ad12a2013-09-24 16:19:11 -070014: vector_(new vector<uint8_t>(initialLength))
15{
16 ndn_DynamicUInt8Array_initialize(this, &vector_->front(), initialLength, DynamicUInt8Vector::realloc);
17}
18
19uint8_t*
Jeff Thompson97223af2013-09-24 17:01:27 -070020DynamicUInt8Vector::realloc(struct ndn_DynamicUInt8Array *self, uint8_t *array, size_t length)
Jeff Thompson10ad12a2013-09-24 16:19:11 -070021{
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}