From: Sandro Santilli Date: Mon, 4 Jul 2011 11:24:32 +0000 (+0000) Subject: Do not hard-code lenght of geomtype struct array (See #1094) X-Git-Tag: 2.0.0alpha1~1268 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a1b0bd03a20ba0e0b9db860f4fed8b61215ca066;p=postgis Do not hard-code lenght of geomtype struct array (See #1094) git-svn-id: http://svn.osgeo.org/postgis/trunk@7574 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/liblwgeom/g_util.c b/liblwgeom/g_util.c index 8f3135e02..ea461c844 100644 --- a/liblwgeom/g_util.c +++ b/liblwgeom/g_util.c @@ -27,7 +27,7 @@ struct geomtype_struct before it. Otherwise if we search for "POINT" at the top of the list we would also match MULTIPOINT, for example. */ -struct geomtype_struct geomtype_struct_array[44] = +struct geomtype_struct geomtype_struct_array[] = { { "GEOMETRYCOLLECTIONZM", COLLECTIONTYPE, 1, 1 }, { "GEOMETRYCOLLECTIONZ", COLLECTIONTYPE, 1, 0 }, @@ -74,6 +74,7 @@ struct geomtype_struct geomtype_struct_array[44] = { "POINTM", POINTTYPE, 0, 1 }, { "POINT", POINTTYPE, 0, 0 } }; +#define GEOMTYPE_STRUCT_ARRAY_LEN (sizeof geomtype_struct_array/sizeof(struct geomtype_struct)) uchar gflags(int hasz, int hasm, int geodetic) @@ -140,7 +141,7 @@ int geometry_type_from_string(const char *str, int *type, int *z, int *m) tmpstr[i - tmpstartpos] = '\0'; /* Now check for the type */ - for (i = 0; i < 44; i++) + for (i = 0; i < GEOMTYPE_STRUCT_ARRAY_LEN; i++) { if (!strcmp(tmpstr, geomtype_struct_array[i].typename)) {