NOAA-EMC / NCEPLIBS-g2c

This library contains C decoder/encoder routines for GRIB edition 2.
Other
18 stars 11 forks source link

reduce sizes of max template maplens #353

Closed edwardhartnett closed 1 year ago

edwardhartnett commented 1 year ago

We have the following in grib2.h.in:

/* Constants to help with templates. */
#define G2C_MAX_GRID_TEMPLATE 31 /**< Maximum number of grid templates. */
#define G2C_MAX_GRID_TEMPLATE_MAPLEN 200 /**< Maximum grid template map length. */
#define G2C_MAX_PDS_TEMPLATE 47 /**< Maximum number of PDS templates. */
#define G2C_MAX_PDS_TEMPLATE_MAPLEN 200 /**< Maximum template map length. */
#define G2C_MAX_DRS_TEMPLATE 9 /**< Maximum number of DRS templates. */
#define G2C_MAX_DRS_TEMPLATE_MAPLEN 200 /**< Maximum DRS template map length. */

Note that the constants which contain the max number of templates are 31, 47, a 9, the exact number of the templates.

But the MAPLEN is 200 in all cases, which is much larger than needed. So we can change the MAPLENs to exactly match the max maplens of each type of template. If we later add a template with a longer maplen, we will immediately get a compile error and will know that we must increase the max maplen for that type of template.