| 676 | } |
| 677 | |
| 678 | static SIValue *Proc_SSpathsStep |
| 679 | ( |
| 680 | ProcedureCtx *ctx |
| 681 | ) { |
| 682 | ASSERT(ctx->privateData != NULL); |
| 683 | |
| 684 | SingleSourceCtx *single_source_ctx = ctx->privateData; |
| 685 | WeightedPath p; |
| 686 | |
| 687 | if(single_source_ctx->path_count == 0) { |
| 688 | if(array_len(single_source_ctx->array) == 0) return NULL; |
| 689 | |
| 690 | p = array_pop(single_source_ctx->array); |
| 691 | } else if(single_source_ctx->path_count == 1) { |
| 692 | p = single_source_ctx->single; |
| 693 | if(p.path == NULL) return NULL; |
| 694 | |
| 695 | single_source_ctx->single.path = NULL; |
| 696 | } else { |
| 697 | WeightedPath *pp = Heap_poll(single_source_ctx->heap); |
| 698 | if(pp == NULL) return NULL; |
| 699 | |
| 700 | p = *pp; |
| 701 | rm_free(pp); |
| 702 | } |
| 703 | |
| 704 | if(single_source_ctx->yield_path) { |
| 705 | *single_source_ctx->yield_path = SI_Path(p.path); |
| 706 | Path_Free(p.path); |
| 707 | } |
| 708 | if(single_source_ctx->yield_path_weight) *single_source_ctx->yield_path_weight = SI_DoubleVal(p.weight); |
| 709 | if(single_source_ctx->yield_path_cost) *single_source_ctx->yield_path_cost = SI_DoubleVal(p.cost); |
| 710 | |
| 711 | return single_source_ctx->output; |
| 712 | } |
| 713 | |
| 714 | static ProcedureResult Proc_SSpathsFree |
| 715 | ( |