Commit 7b886daf authored by Thomas Jahns's avatar Thomas Jahns 🤸
Browse files

Change grid unpack to force resource IDs.

parent 657bca99
......@@ -157,15 +157,18 @@ void grid_free(grid_t *gridptr)
grid_init(gridptr);
}
static
grid_t *gridNewEntry ( void )
static grid_t *
gridNewEntry(cdiResH resH)
{
grid_t *gridptr;
gridptr = ( grid_t *) xmalloc ( sizeof ( grid_t ));
grid_init ( gridptr );
gridptr->self = reshPut (( void * ) gridptr, &gridOps );
grid_t *gridptr = xmalloc(sizeof (grid_t));
grid_init(gridptr);
if (resH == CDI_UNDEFID)
gridptr->self = reshPut(gridptr, &gridOps);
else
{
gridptr->self = resH;
reshReplace(resH, gridptr, &gridOps);
}
return gridptr;
}
......@@ -395,7 +398,7 @@ int gridCreate(int gridtype, int size)
gridInit();
gridptr = gridNewEntry();
gridptr = gridNewEntry(CDI_UNDEFID);
if ( ! gridptr ) Error("No memory");
gridID = gridptr->self;
......@@ -4525,7 +4528,8 @@ gridGetPackSize(void * voidP, void *context)
void
gridUnpack(char * unpackBuffer, int unpackBufferSize,
int * unpackBufferPos, int nspTarget, void *context)
int * unpackBufferPos, int nspTarget, void *context,
int force_id)
{
grid_t * gridP;
uint32_t d;
......@@ -4534,8 +4538,6 @@ gridUnpack(char * unpackBuffer, int unpackBufferSize,
gridInit();
gridP = gridNewEntry();
xassert(gridP);
{
int intBuffer[gridNint];
serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
......@@ -4544,7 +4546,10 @@ gridUnpack(char * unpackBuffer, int unpackBufferSize,
&d, 1, DATATYPE_UINT32, context);
xassert(cdiCheckSum(DATATYPE_INT, gridNint, intBuffer) == d);
xassert(namespaceAdaptKey(intBuffer[0], nspTarget) == gridP->self);
int targetID = namespaceAdaptKey(intBuffer[0], nspTarget);
gridP = gridNewEntry(force_id?targetID:CDI_UNDEFID);
xassert(!force_id || targetID == gridP->self);
gridP->type = intBuffer[1];
gridP->prec = intBuffer[2];
......
......@@ -87,6 +87,11 @@ int gridGenerate(grid_t grid);
void gridGetIndexList( int, int * );
void
gridUnpack(char * unpackBuffer, int unpackBufferSize,
int * unpackBufferPos, int nspTarget, void *context,
int force_id);
#endif
/*
* Local Variables:
......
......@@ -4,6 +4,7 @@
#include "cdi.h"
#include "dmemory.h"
#include "grid.h"
#include "institution.h"
#include "model.h"
#include "cdi_int.h"
......@@ -14,12 +15,8 @@
#include "taxis.h"
#include "zaxis.h"
extern void gridUnpack ( char *, int, int *, int, void *context);
/*****************************************************************************/
void reshUnpackResources(char * unpackBuffer, int unpackBufferSize,
void *context)
{
......@@ -44,7 +41,7 @@ void reshUnpackResources(char * unpackBuffer, int unpackBufferSize,
break;
case GRID:
gridUnpack(unpackBuffer, unpackBufferSize, &unpackBufferPos,
nspTarget, context );
nspTarget, context, 1);
break;
case ZAXIS:
zaxisUnpack(unpackBuffer, unpackBufferSize, &unpackBufferPos,
......
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