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