* flatten_into method for expanded arrays */
| 290 | * flatten_into method for expanded arrays |
| 291 | */ |
| 292 | static void |
| 293 | EA_flatten_into(ExpandedObjectHeader *eohptr, |
| 294 | void *result, Size allocated_size) |
| 295 | { |
| 296 | ExpandedArrayHeader *eah = (ExpandedArrayHeader *) eohptr; |
| 297 | ArrayType *aresult = (ArrayType *) result; |
| 298 | int nelems; |
| 299 | int ndims; |
| 300 | int32 dataoffset; |
| 301 | |
| 302 | Assert(eah->ea_magic == EA_MAGIC); |
| 303 | |
| 304 | /* Easy if we have a valid flattened value */ |
| 305 | if (eah->fvalue) |
| 306 | { |
| 307 | Assert(allocated_size == ARR_SIZE(eah->fvalue)); |
| 308 | memcpy(result, eah->fvalue, allocated_size); |
| 309 | return; |
| 310 | } |
| 311 | |
| 312 | /* Else allocation should match previous get_flat_size result */ |
| 313 | Assert(allocated_size == eah->flat_size); |
| 314 | |
| 315 | /* Fill result array from dvalues/dnulls */ |
| 316 | nelems = eah->nelems; |
| 317 | ndims = eah->ndims; |
| 318 | |
| 319 | if (eah->dnulls) |
| 320 | dataoffset = ARR_OVERHEAD_WITHNULLS(ndims, nelems); |
| 321 | else |
| 322 | dataoffset = 0; /* marker for no null bitmap */ |
| 323 | |
| 324 | /* We must ensure that any pad space is zero-filled */ |
| 325 | memset(aresult, 0, allocated_size); |
| 326 | |
| 327 | SET_VARSIZE(aresult, allocated_size); |
| 328 | aresult->ndim = ndims; |
| 329 | aresult->dataoffset = dataoffset; |
| 330 | aresult->elemtype = eah->element_type; |
| 331 | memcpy(ARR_DIMS(aresult), eah->dims, ndims * sizeof(int)); |
| 332 | memcpy(ARR_LBOUND(aresult), eah->lbound, ndims * sizeof(int)); |
| 333 | |
| 334 | CopyArrayEls(aresult, |
| 335 | eah->dvalues, eah->dnulls, nelems, |
| 336 | eah->typlen, eah->typbyval, eah->typalign, |
| 337 | false); |
| 338 | } |
| 339 | |
| 340 | /* |
| 341 | * Argument fetching support code |
nothing calls this directly
no test coverage detected