Commit 0b68bba9 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Moved ensureBufferSize() to stream_grb.c.

parent efb14e97
......@@ -2,6 +2,7 @@
#include "config.h"
#endif
#include "dmemory.h"
#include "cdi.h"
#include "cdi_int.h"
#include "stream_cgribex.h"
......@@ -20,6 +21,16 @@ int cdiGribUseTimeRangeIndicator = 0; // normaly cdo looks in grib
#endif // HIRLAM_EXTENSIONS
void ensureBufferSize(size_t requiredSize, size_t *curSize, void **buffer)
{
if ( *curSize < requiredSize )
{
*curSize = requiredSize;
*buffer = Realloc(*buffer, *curSize);
}
}
// Regarding operation to change parameter identification:
// change if cdiGribChangeParameterID.active
struct cdiGribParamChange cdiGribChangeParameterID;
......
#ifndef _STREAM_GRB_H
#define _STREAM_GRB_H
#ifndef STREAM_GRB_H
#define STREAM_GRB_H
void ensureBufferSize(size_t requiredSize, size_t *curSize, void **buffer);
static inline bool gribbyte_get_bit(int number, int bit) { return (bool)((number >> (8-bit)) & 1); }
static inline void gribbyte_set_bit(int *number, int bit) { *number |= 1 << (8-bit); }
......@@ -58,7 +60,7 @@ void streamGrbChangeModeUvRelativeToGrid(int mode);
void streamGrbDefDataScanningMode(int scanmode);
int streamGrbInqDataScanningMode(void);
#endif /* _STREAM_GRB_H */
#endif /* STREAM_GRB_H */
/*
* Local Variables:
* c-file-style: "Java"
......
......@@ -816,20 +816,10 @@ int gribapiVarCompare(compvar2_t compVar, record_t record, int flag)
return memcmp(&compVar0, &compVar, sizeof(compvar2_t));
}
static
void ensureBufferSize(size_t requiredSize, size_t *curSize, void **buffer)
{
if ( *curSize < requiredSize )
{
*curSize = requiredSize;
*buffer = Realloc(*buffer, *curSize);
}
}
static
grib_handle *gribapiGetDiskRepresentation(size_t recsize, size_t *buffersize, void **gribbuffer, int *outDatatype, int *outCompressionType, size_t *outUnzipsize)
{
int gribversion = (int)((char*)*gribbuffer)[7];
const int gribversion = (int)((char*)*gribbuffer)[7];
if ( gribversion <= 1 )
{
......
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