From ebeac3baaa8d0ebdab025f4f4eacbf7fe360e89b Mon Sep 17 00:00:00 2001 From: Kaj-Michael Lang Date: Thu, 13 Mar 2008 16:36:03 +0200 Subject: [PATCH] Add path_new and path_free. No need to set fields two 0 in macro. --- src/path.c | 17 +++++++++++++++++ src/path.h | 4 +++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/path.c b/src/path.c index 9dc7d01..df0ce1c 100644 --- a/src/path.c +++ b/src/path.c @@ -11,6 +11,23 @@ #include "settings.h" #include "latlon.h" +Path * +path_new(void) +{ +Path *p; + +p=g_slice_new0(Path); +MACRO_PATH_INIT(*p); +return p; +} + +void +path_free(Path *p) +{ +MACRO_PATH_FREE(*p); +g_slice_free(Path, p); +} + void path_resize(Path *path, guint size) { diff --git a/src/path.h b/src/path.h index ac9da80..f5cc4e0 100644 --- a/src/path.h +++ b/src/path.h @@ -11,7 +11,6 @@ (path).whead = g_new0(WayPoint, ARRAY_CHUNK_SIZE); \ (path).wtail = (path).whead - 1; \ (path).wcap = (path).whead + ARRAY_CHUNK_SIZE; \ - (path).length=(path).maxspeed=(path).tspeed=(path).avgspeed=(path).points=0; \ } #define MACRO_PATH_FREE(path) if((path).head) { \ @@ -99,6 +98,9 @@ Point _point_null; Position _home; Position _dest; +Path *path_new(void); +void path_free(Path *p); + void path_resize(Path *path, guint size); void path_wresize(Path *path, guint wsize); -- 2.39.5