]> granicus.if.org Git - postgis/commitdiff
Do not hard-code lenght of geomtype struct array (See #1094)
authorSandro Santilli <strk@keybit.net>
Mon, 4 Jul 2011 11:24:32 +0000 (11:24 +0000)
committerSandro Santilli <strk@keybit.net>
Mon, 4 Jul 2011 11:24:32 +0000 (11:24 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@7574 b70326c6-7e19-0410-871a-916f4a2858ee

liblwgeom/g_util.c

index 8f3135e0250e433eb7dee93123422a1438e05a61..ea461c844166ef1c8a9c4b9f97529d0a086017d8 100644 (file)
@@ -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))
                {