]> err.no Git - mapper/blobdiff - src/path.h
Fix GPS settings dialog so it works.
[mapper] / src / path.h
index fc4516eb19c795094bbed11a6b721105eeefa0ac..12ed0ab82f0251639a8f78eb03d931f2418076f9 100644 (file)
@@ -3,6 +3,36 @@
 
 #include <glib.h>
 
+#define MACRO_PATH_INIT(path) { \
+    (path).head = (path).tail = g_new(Point, ARRAY_CHUNK_SIZE); \
+    *((path).tail) = _point_null; \
+    (path).cap = (path).head + ARRAY_CHUNK_SIZE; \
+    (path).whead = g_new(WayPoint, ARRAY_CHUNK_SIZE); \
+    (path).wtail = (path).whead - 1; \
+    (path).wcap = (path).whead + ARRAY_CHUNK_SIZE; \
+}
+
+#define MACRO_PATH_FREE(path) if((path).head) { \
+    WayPoint *curr; \
+    g_free((path).head); \
+    (path).head = (path).tail = (path).cap = NULL; \
+    for(curr = (path).whead - 1; curr++ != (path).wtail; ) \
+        g_free(curr->desc); \
+    g_free((path).whead); \
+    (path).whead = (path).wtail = (path).wcap = NULL; \
+}
+
+#define MACRO_PATH_INCREMENT_TAIL(route) { \
+    if(++(route).tail == (route).cap) \
+        path_resize(&(route), (route).cap - (route).head + ARRAY_CHUNK_SIZE);\
+}
+
+#define MACRO_PATH_INCREMENT_WTAIL(route) { \
+    if(++(route).wtail == (route).wcap) \
+        path_wresize(&(route), \
+                (route).wcap - (route).whead + ARRAY_CHUNK_SIZE); \
+}
+
 /** A lat/lon/alt position */
 typedef struct _Position Position;
 struct _Position {