From eaeb55bf719a45a12231abe95f18128b5ed6bec3 Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Tue, 2 Dec 2014 18:03:07 -0800 Subject: [PATCH] Distinguish between signed and unsigned in the temporary file --- geojson.c | 5 +++++ geometry.cc | 6 +++--- tile.h | 1 + 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/geojson.c b/geojson.c index eaa64e0..79ef40e 100644 --- a/geojson.c +++ b/geojson.c @@ -179,6 +179,11 @@ void deserialize_int(char **f, int *n) { *f += sizeof(int); } +void deserialize_uint(char **f, unsigned *n) { + memcpy(n, *f, sizeof(unsigned)); + *f += sizeof(unsigned); +} + void deserialize_byte(char **f, signed char *n) { memcpy(n, *f, sizeof(signed char)); *f += sizeof(signed char); diff --git a/geometry.cc b/geometry.cc index daecdce..2b5491a 100644 --- a/geometry.cc +++ b/geometry.cc @@ -28,9 +28,9 @@ drawvec decode_geometry(char **meta, int z, unsigned tx, unsigned ty, int detail } if (d.op == VT_MOVETO || d.op == VT_LINETO) { - int wx, wy; - deserialize_int(meta, &wx); - deserialize_int(meta, &wy); + unsigned wx, wy; + deserialize_uint(meta, &wx); + deserialize_uint(meta, &wy); long long wwx = (unsigned) wx; long long wwy = (unsigned) wy; diff --git a/tile.h b/tile.h index f4f38e6..0fe8a03 100644 --- a/tile.h +++ b/tile.h @@ -14,6 +14,7 @@ struct pool; void deserialize_int(char **f, int *n); +void deserialize_uint(char **f, unsigned *n); void deserialize_byte(char **f, signed char *n); struct pool_val *deserialize_string(char **f, struct pool *p, int type);