diff options
Diffstat (limited to 'path.c')
| -rw-r--r-- | path.c | 15 |
1 files changed, 9 insertions, 6 deletions
@@ -332,6 +332,7 @@ void path_free(Path path, size_t height) { void path_reverse(Path *path, size_t width, size_t height, Position *start, Position *end) { Path new_path = path_new(width, height); + if (new_path == NULL) error("Failed to allocate path\n"); Position cur = *end; while (cur.x != start->x || cur.y != start->y) { @@ -341,16 +342,18 @@ void path_reverse(Path *path, size_t width, size_t height, Position *start, Posi } /* Switch start and end around */ - start->x = start->x ^ end->x; - end->x = start->x ^ end->x; - start->x = start->x ^ end->x; + start->x ^= end->x; + end->x ^= start->x; + start->x ^= end->x; - start->y = start->y ^ end->y; - end->y = start->y ^ end->y; - start->y = start->y ^ end->y; + start->y ^= end->y; + end->y ^= start->y; + start->y ^= end->y; path_free(*path, height); *path = new_path; + + return; } char **visited_new(size_t width, size_t height) { |
