]> err.no Git - mapper/blob - src/path.c
Code cleanups
[mapper] / src / path.c
1 #include <config.h>
2
3 #include "utils.h"
4 #include "map.h"
5 #include "route.h"
6 #include "mapper-types.h"
7
8 #include "track.h"
9
10 void 
11 path_resize(Path * path, guint size)
12 {
13 if (path->head + size != path->cap) {
14         Point *old_head = path->head;
15         WayPoint *curr;
16         path->head = g_renew(Point, old_head, size);
17         path->cap = path->head + size;
18         if (path->head != old_head) {
19                 path->tail = path->head + (path->tail - old_head);
20
21                 /* Adjust all of the waypoints. */
22                 for (curr = path->whead - 1; curr++ != path->wtail;)
23                         curr->point =
24                             path->head + (curr->point - old_head);
25         }
26 }
27 }
28
29 void 
30 path_wresize(Path * path, guint wsize)
31 {
32 if (path->whead + wsize != path->wcap) {
33         WayPoint *old_whead = path->whead;
34         path->whead = g_renew(WayPoint, old_whead, wsize);
35         path->wtail = path->whead + (path->wtail - old_whead);
36         path->wcap = path->whead + wsize;
37 }
38 }