From: Björn Harrtell Date: Wed, 19 Apr 2017 17:43:18 +0000 (+0000) Subject: Clear hash tables after usage X-Git-Tag: 2.4.0alpha~134 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6476e4ec1e7ccfbfd52a5820542bb56d0dbdcb58;p=postgis Clear hash tables after usage git-svn-id: http://svn.osgeo.org/postgis/trunk@15354 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/postgis/mvt.c b/postgis/mvt.c index 1d5ea594c..564f61f36 100644 --- a/postgis/mvt.c +++ b/postgis/mvt.c @@ -190,7 +190,7 @@ static void encode_mline(struct mvt_agg_context *ctx, LWMLINE *lwmline) c += 2 + lwmline->geoms[i]->points->npoints * 2; feature->geometry = palloc(sizeof(*feature->geometry) * c); for (i = 0; i < lwmline->ngeoms; i++) - offset += encode_ptarray(ctx, MVT_LINE, + offset += encode_ptarray(ctx, MVT_LINE, lwmline->geoms[i]->points, feature->geometry + offset, &px, &py); feature->n_geometry = offset; @@ -328,6 +328,13 @@ static void encode_values(struct mvt_agg_context *ctx) ctx->layer->n_values = ctx->values_hash_i; ctx->layer->values = values; + + HASH_CLEAR(hh, ctx->string_values_hash); + HASH_CLEAR(hh, ctx->float_values_hash); + HASH_CLEAR(hh, ctx->double_values_hash); + HASH_CLEAR(hh, ctx->uint_values_hash); + HASH_CLEAR(hh, ctx->sint_values_hash); + HASH_CLEAR(hh, ctx->bool_values_hash); } #define MVT_PARSE_VALUE(value, kvtype, hash, valuefield, size) \ @@ -463,7 +470,7 @@ static int max_dim(LWCOLLECTION *lwcoll) * Makes best effort to keep validity. Might collapse geometry into lower * dimension. */ -LWGEOM *mvt_geom(LWGEOM *lwgeom, GBOX *gbox, uint32_t extent, uint32_t buffer, +LWGEOM *mvt_geom(LWGEOM *lwgeom, GBOX *gbox, uint32_t extent, uint32_t buffer, bool clip_geom) { double width = gbox->xmax - gbox->xmin; @@ -533,7 +540,7 @@ LWGEOM *mvt_geom(LWGEOM *lwgeom, GBOX *gbox, uint32_t extent, uint32_t buffer, /** * Initialize aggregation context. */ -void mvt_agg_init_context(struct mvt_agg_context *ctx) +void mvt_agg_init_context(struct mvt_agg_context *ctx) { VectorTile__Tile__Layer *layer; @@ -544,7 +551,6 @@ void mvt_agg_init_context(struct mvt_agg_context *ctx) ctx->string_values_hash = NULL; ctx->float_values_hash = NULL; ctx->double_values_hash = NULL; - ctx->int_values_hash = NULL; ctx->uint_values_hash = NULL; ctx->sint_values_hash = NULL; ctx->bool_values_hash = NULL; @@ -628,4 +634,4 @@ uint8_t *mvt_agg_finalfn(struct mvt_agg_context *ctx) return buf; } -#endif \ No newline at end of file +#endif diff --git a/postgis/mvt.h b/postgis/mvt.h index b2f87476a..02b3d57a3 100644 --- a/postgis/mvt.h +++ b/postgis/mvt.h @@ -31,7 +31,7 @@ #include "utils/array.h" #include "utils/typcache.h" #include "utils/lsyscache.h" -#include "catalog/pg_type.h" +#include "catalog/pg_type.h" #include "executor/executor.h" #include "access/htup_details.h" #include "access/htup.h" @@ -57,7 +57,6 @@ struct mvt_agg_context { struct mvt_kv_string_value *string_values_hash; struct mvt_kv_float_value *float_values_hash; struct mvt_kv_double_value *double_values_hash; - struct mvt_kv_int_value *int_values_hash; struct mvt_kv_uint_value *uint_values_hash; struct mvt_kv_sint_value *sint_values_hash; struct mvt_kv_bool_value *bool_values_hash; @@ -72,4 +71,4 @@ uint8_t *mvt_agg_finalfn(struct mvt_agg_context *ctx); #endif /* HAVE_LIBPROTOBUF */ -#endif \ No newline at end of file +#endif