MCPcopy Create free account
hub / github.com/apache/madlib / reallocSvec

Function reallocSvec

methods/svec/src/pg_gp/sparse_vector.c:369–389  ·  view source on GitHub ↗

* Allocates more space for the count and data arrays of an svec */

Source from the content-addressed store, hash-verified

367 * Allocates more space for the count and data arrays of an svec
368 */
369SvecType *reallocSvec(SvecType *source)
370{
371 SvecType *svec;
372 SparseData sdata = sdata_from_svec(source);
373 int val_newmaxlen = Max(2*sizeof(float8)+1, 2 * (Size) sdata->vals->maxlen);
374 char *newvals = (char *)palloc(val_newmaxlen);
375 int ind_newmaxlen = Max(2*sizeof(int8)+1, 2 * (Size) sdata->index->maxlen);
376 char *newindex = (char *)palloc(ind_newmaxlen);
377 /*
378 * This space was never allocated with palloc, so we can't repalloc it!
379 */
380 memcpy(newvals ,sdata->vals->data ,sdata->vals->len);
381 memcpy(newindex,sdata->index->data,sdata->index->len);
382 sdata->vals->data = newvals;
383 sdata->vals->maxlen = val_newmaxlen;
384 sdata->index->data = newindex;
385 sdata->index->maxlen = ind_newmaxlen;
386 svec = svec_from_sparsedata(sdata,false);
387// pfree(source);
388 return(svec);
389}
390
391 //

Callers 1

svec_pivotFunction · 0.85

Calls 2

sdata_from_svecFunction · 0.85
svec_from_sparsedataFunction · 0.85

Tested by

no test coverage detected