From 03031e02aa21809afa1809805283d0ed62fbcd42 Mon Sep 17 00:00:00 2001 From: c9s Date: Wed, 18 Nov 2015 14:27:28 +0800 Subject: [PATCH] Fix r3 json writer --- .travis.yml | 3 --- include/r3_json.h | 10 +++++----- src/json.c | 12 ++++++------ tests/Makefile.am | 3 +-- tests/check_json.c | 2 +- 5 files changed, 13 insertions(+), 17 deletions(-) diff --git a/.travis.yml b/.travis.yml index 158dd9c..c613e37 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,5 @@ language: c -compiler: - - gcc - git: depth: 1 diff --git a/include/r3_json.h b/include/r3_json.h index 3f8b114..e8b4b87 100644 --- a/include/r3_json.h +++ b/include/r3_json.h @@ -11,13 +11,13 @@ #include #include "r3.h" -json_object * r3_edge_to_json_object(const edge * e); -json_object * r3_node_to_json_object(const node * n); +json_object * r3_edge_to_json_object(const R3Edge * e); +json_object * r3_node_to_json_object(const R3Node * n); json_object * r3_route_to_json_object(const R3Route * r); -const char * r3_node_to_json_string_ext(const node * n, int options); -const char * r3_node_to_json_pretty_string(const node * n); -const char * r3_node_to_json_string(const node * n); +const char * r3_node_to_json_string_ext(const R3Node * n, int options); +const char * r3_node_to_json_pretty_string(const R3Node * n); +const char * r3_node_to_json_string(const R3Node * n); diff --git a/src/json.c b/src/json.c index 0b17d22..18b72a2 100644 --- a/src/json.c +++ b/src/json.c @@ -27,7 +27,7 @@ json_object * r3_route_to_json_object(const R3Route * r) { } -json_object * r3_edge_to_json_object(const edge * e) { +json_object * r3_edge_to_json_object(const R3Edge * e) { json_object *obj; obj = json_object_new_object(); @@ -42,7 +42,7 @@ json_object * r3_edge_to_json_object(const edge * e) { return obj; } -json_object * r3_node_to_json_object(const node * n) { +json_object * r3_node_to_json_object(const R3Node * n) { json_object *obj; obj = json_object_new_object(); @@ -60,7 +60,7 @@ json_object * r3_node_to_json_object(const node * n) { json_object *edges_array = json_object_new_array(); json_object_object_add(obj, "edges", edges_array); for (i = 0 ; i < n->edge_len ; i++ ) { - json_object *edge_json_obj = r3_edge_to_json_object(n->edges[i]); + json_object *edge_json_obj = r3_edge_to_json_object(&n->edges[i]); json_object_array_add(edges_array, edge_json_obj); } } @@ -79,17 +79,17 @@ json_object * r3_node_to_json_object(const node * n) { } -const char * r3_node_to_json_string_ext(const node * n, int options) { +const char * r3_node_to_json_string_ext(const R3Node * n, int options) { json_object *obj = r3_node_to_json_object(n); return json_object_to_json_string_ext(obj, options); } -const char * r3_node_to_json_pretty_string(const node * n) { +const char * r3_node_to_json_pretty_string(const R3Node * n) { json_object *obj = r3_node_to_json_object(n); return json_object_to_json_string_ext(obj, JSON_C_TO_STRING_PRETTY | JSON_C_TO_STRING_SPACED); } -const char * r3_node_to_json_string(const node * n) { +const char * r3_node_to_json_string(const R3Node * n) { json_object *obj = r3_node_to_json_object(n); return json_object_to_json_string(obj); } diff --git a/tests/Makefile.am b/tests/Makefile.am index cda7987..196c6c8 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,6 +1,6 @@ TESTS = -AM_CFLAGS=$(DEPS_CFLAGS) $(GVC_DEPS_CFLAGS) $(JSONC_CFLAGS) @CHECK_CFLAGS@ -I$(top_builddir) -I$(top_builddir)/include -I$(top_builddir)/src -I$(top_builddir)/3rdparty -Wall -std=c99 -ggdb -Wall +AM_CFLAGS=$(DEPS_CFLAGS) $(GVC_DEPS_CFLAGS) $(JSONC_CFLAGS) @CHECK_CFLAGS@ -I$(top_builddir) -I$(top_builddir)/include -I$(top_builddir)/src -I$(top_builddir)/3rdparty -Wall -std=c99 -ggdb AM_LDFLAGS=$(DEPS_LIBS) $(GVC_DEPS_LIBS) $(JSONC_LIBS) @CHECK_LIBS@ $(top_builddir)/libr3.la if USE_JEMALLOC @@ -49,4 +49,3 @@ bench_SOURCES = bench.c # AM_CFLAGS=$(DEPS_CFLAGS) -I$(top_builddir)/include # AM_CFLAGS=$(DEPS_CFLAGS) -I$(top_builddir) -I$(top_builddir)/include CLEANFILES = check_tree.log - diff --git a/tests/check_json.c b/tests/check_json.c index 1fa48fe..ae2d467 100644 --- a/tests/check_json.c +++ b/tests/check_json.c @@ -16,7 +16,7 @@ START_TEST (test_json_encode) { - node * n; + R3Node * n; n = r3_tree_create(10); ck_assert(n);