Commit d677659b authored by Thomas Jahns's avatar Thomas Jahns 🤸
Browse files

Convert trivial wrappers to inline functions.

parent 9a30ba0f
......@@ -59,7 +59,7 @@ void gribContainersNew(stream_t * streamptr)
int editionNumber = 2;
if ( streamptr->filetype == FILETYPE_GRB ) editionNumber = 1;
(void)editionNumber;
#if defined (HAVE_LIBCGRIBEX)
if ( streamptr->filetype == FILETYPE_GRB )
{
......
#ifndef _GRIBAPI_H
#define _GRIBAPI_H
#ifdef HAVE_LIBGRIBAPI
# include "error.h"
# include <grib_api.h>
#endif
#define GRIBAPI_MISSVAL -9.E33
/* GRIB2 Level Types */
......@@ -45,8 +50,25 @@
const char *gribapiLibraryVersionString(void);
void gribContainersNew(stream_t * streamptr);
void gribContainersDelete(stream_t * streamptr);
void *gribHandleNew(int editionNumber);
void gribHandleDelete(void *gh);
#ifdef HAVE_LIBGRIBAPI
static inline void *gribHandleNew(int editionNumber)
{
void *gh = (editionNumber == 1) ?
(void *) grib_handle_new_from_samples(NULL, "GRIB1") :
(void *) grib_handle_new_from_samples(NULL, "GRIB2");
if ( gh == NULL ) Error("grib_handle_new_from_samples failed!");
return gh;
}
static inline void gribHandleDelete(void *gh)
{
grib_handle_delete(gh);
}
#else
#define gribHandleNew(editionNumber) (NULL)
#define gribHandleDelete(gh)
#endif
typedef struct {
int init;
......
......@@ -3088,30 +3088,6 @@ void gribapiDefLevel(int editionNumber, grib_handle *gh, int param, int zaxisID,
}
#endif
void *gribHandleNew(int editionNumber)
{
void *gh = NULL;
#if defined (HAVE_LIBGRIB_API)
if ( editionNumber == 1 )
gh = (void *) grib_handle_new_from_samples(NULL, "GRIB1");
else
gh = (void *) grib_handle_new_from_samples(NULL, "GRIB2");
if ( gh == NULL ) Error("grib_handle_new_from_samples failed!");
#endif
return (gh);
}
void gribHandleDelete(void *gh)
{
#if defined (HAVE_LIBGRIB_API)
grib_handle_delete(gh);
#endif
}
/* #define GRIBAPIENCODETEST 1 */
#ifdef HAVE_LIBGRIB_API
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment