* Allocates more space for the count and data arrays of an svec */
| 367 | * Allocates more space for the count and data arrays of an svec |
| 368 | */ |
| 369 | SvecType *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 | // |
no test coverage detected