Fix r3 json writer

This commit is contained in:
c9s 2015-11-18 14:27:28 +08:00
parent c3ef959539
commit 03031e02aa
5 changed files with 13 additions and 17 deletions

View file

@ -1,8 +1,5 @@
language: c
compiler:
- gcc
git:
depth: 1

View file

@ -11,13 +11,13 @@
#include <json-c/json.h>
#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);

View file

@ -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);
}

View file

@ -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

View file

@ -16,7 +16,7 @@
START_TEST (test_json_encode)
{
node * n;
R3Node * n;
n = r3_tree_create(10);
ck_assert(n);