void Buffer::ensureWritableBytes(size_t len) { if (writableBytes() < len) { makeSpace(len); } assert(writableBytes() >= len); }
/** Expand the space available for this Dlist. * Rebuilds old value in new space. * @param size is the size of the expanded object. */ void Dlist::expand(int size) { int old_n = n(); List::expand(size); if (n() == old_n) return; index *old_pred = pred; makeSpace(); std::copy(old_pred, old_pred+old_n+1, pred); std::fill(pred+old_n+1, pred+n()+1, -1); delete [] old_pred; }
/** Assignment operator (copy). * @param other is a reference to a list to be compared to this * @return true if the two lists are equal */ Dlist& Dlist::operator=(const Dlist& src) { if (this == &src) return *this; int old_n = n(); List::operator=(src); // copy parent class data if (n() != old_n) { // parent resized, do likewise freeSpace(); makeSpace(); } init(); for (index x = src.first(); x != 0; x = src.next(x)) pred[x] = src.pred[x]; return *this; }
bool GrIndexBufferAllocPool::appendIndices(int indexCount, const void* indices, const GrIndexBuffer** buffer, int* startIndex) { void* space = makeSpace(indexCount, buffer, startIndex); if (NULL != space) { memcpy(space, indices, sizeof(uint16_t) * indexCount); return true; } else { return false; } }
// -------------------------------------------------> // Allocates memory for a word and initializes it. // -------------------------------------------------> struct word *initializeWord(char *givenWord) { struct word *word = makeSpace(sizeof(struct word)); int wordLength = strlen(givenWord); char *name = makeSpace(wordLength + 1); strcpy(name, givenWord); word->name = name; word->step = -1; word->numNearby = 0; word->length = wordLength; word->linkedWord = NULL; word->nearby = NULL; word->ladder = NULL; word->nextWord = NULL; return word; }
bool GrVertexBufferAllocPool::appendVertices(GrVertexLayout layout, int vertexCount, const void* vertices, const GrVertexBuffer** buffer, int* startVertex) { void* space = makeSpace(layout, vertexCount, buffer, startVertex); if (NULL != space) { memcpy(space, vertices, GrDrawTarget::VertexSize(layout) * vertexCount); return true; } else { return false; } }
bool GrVertexBufferAllocPool::appendVertices(size_t vertexSize, int vertexCount, const void* vertices, const GrVertexBuffer** buffer, int* startVertex) { void* space = makeSpace(vertexSize, vertexCount, buffer, startVertex); if (NULL != space) { memcpy(space, vertices, vertexSize * vertexCount); return true; } else { return false; } }
// Construct a copy of a graph from a given graph digraph::digraph(const digraph& G) : graph(G) { makeSpace(); copyFrom(G); }
// Construct a graph with space for N1 vertices and mM1 edges. digraph::digraph(int mN1, int mM1) : graph(mN1,mM1) { makeSpace(); }
void digraph::mSpace() { graph::mSpace(); makeSpace(); }
ReaderPacker(Reader content) : packedMessage(makeSpace(content)), outs(packedMessage) { capnp::writePackedMessage(outs, message); }
/** Default constructor for Dlist objects. */ Dlist::Dlist() : List() { makeSpace(); init(); }
/** Resize the flograph. * The old flograph is discarded and new space allocated. * @param numv is the number of vertices in the graph * @param maxe is the max number of edges in the graph */ void Wflograph::resize(int numv, int maxe) { Flograph::resize(numv, maxe); freeSpace(); makeSpace(numv, maxe); }
/** Resize a Dlists_r object. * The old value is discarded. * @param size is the size of the resized object. */ void Dlists_r::resize(int size) { freeSpace(); makeSpace(); clear(); }
/** Resize a Graph object. * The old value is discarded. * @param numv is the number of vertices to allocate space for * @param maxe is the number of edges to allocate space for */ void Graph::resize(int numv, int maxe) { freeSpace(); Adt::resize(numv); makeSpace(numv,maxe); init(); }
/** Constructor for Ssets2k class. * @param n defines the index range for the constructed object. */ Ssets2k::Ssets2k(int n) : Ssets_rbt(n) { makeSpace(); init(); }
/** Resize a RlistSet object. * The old value is discarded. * @param size is the size of the resized object. */ void RlistSet::resize(int size) { freeSpace(); makeSpace(); clear(); }
/** Resize a Dlist object. * The old value is discarded. * @param size is the size of the resized object. */ void Dlist::resize(int size) { freeSpace(); List::resize(size); makeSpace(); init(); }
/** Copy constructor. * @param src is a Dlist whose contents are copied to this Dlist. */ Dlist::Dlist(const Dlist& src) : List(src) { makeSpace(); init(); for (index x = src.first(); x != 0; x = src.next(x)) pred[x] = src.pred[x]; }
/** Constructor for Dlist objects with explicit index range. * @param n specifies the maximum index */ Dlist::Dlist(int n) : List(n) { makeSpace(); init(); }
int placeAtEnd (queue *q, item item) { makeSpace (q, q->size + 1); q->root[q->size] = item; return q->size++; }
/** Constructor for RlistSet class. * @param n defines the index set for the new object */ RlistSet::RlistSet(int n) : Adt(n) { makeSpace(); clear(); }
/** Constructor for Dlists_r class. * @param n defines the index set for the new object */ Dlists_r::Dlists_r(int n) : Adt(n) { makeSpace(); clear(); }
/** Constructor for DkBstSet class. * @param n defines the index range for the constructed object. */ DkBstSet::DkBstSet(int n) : BalBstSet(n) { makeSpace(); init(); }
/** Construct a Wflograph. * @param numv is the number of vertices in the graph * @param maxe is the max number of edges in the graph * @param s1 is the source vertex * @param t1 is the sink vertex */ Wflograph::Wflograph(int numv, int maxe, int s1, int t1) : Flograph(numv, maxe, s1, t1) { makeSpace(numv,maxe); }
/** Resize a DkBstSet object, discarding old value. * @param n is the size of the resized object. */ void DkBstSet::resize(int n) { freeSpace(); BalBstSet::resize(n); makeSpace(); init(); }
/** Constructor for PathSet class. * @param n defines the index range for the constructed object. * @param pathVals is a vector of integer values, which is defined for * each path in the set; that is if u is the handle of some path, * then pathVals[u] will be an integer which the application using * the PathSet has defined for the path; since the PathSet object * may change the handle of a path as a side effect of any operation, * the PathSet object updates pathVals whenever the handle for a path * changes */ PathSet::PathSet(int n, int *pathVals) : Adt(n), pvals(pathVals) { makeSpace(); clear(); }
/** Resize a Ssets2k object, discarding old value. * @param n is the size of the resized object. */ void Ssets2k::resize(int n) { freeSpace(); Ssets_rbt::resize(n); makeSpace(); init(); }
/** Resize a PathSet object, discarding old value. * @param n is the size of the resized object. */ void PathSet::resize(int n) { freeSpace(); Adt::resize(n); makeSpace(); clear(); }
/** Resize a Partition object. * The old value is discarded. * @param n is the size of the resized object. */ void Partition::resize(int n) { freeSpace(); Adt::resize(n); makeSpace(); }