* Convert the list of ScanKey to the array, and append an emtpy ScanKey as * the end flag of the array. */
| 450 | * the end flag of the array. |
| 451 | */ |
| 452 | static ScanKey |
| 453 | ScanKeyListToArray(List *keys, int *num) |
| 454 | { |
| 455 | ScanKey sk; |
| 456 | |
| 457 | if (list_length(keys) == 0) |
| 458 | return NULL; |
| 459 | |
| 460 | Assert(num); |
| 461 | *num = list_length(keys); |
| 462 | |
| 463 | sk = (ScanKey)palloc(sizeof(ScanKeyData) * (*num + 1)); |
| 464 | for (int i = 0; i < *num; ++i) |
| 465 | memcpy(&sk[i], list_nth(keys, i), sizeof(ScanKeyData)); |
| 466 | |
| 467 | /* |
| 468 | * SK_EMPYT means the end of the array of the ScanKey |
| 469 | */ |
| 470 | sk[*num].sk_flags = SK_EMPYT; |
| 471 | |
| 472 | return sk; |
| 473 | } |
no test coverage detected