Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mpim-sw
libcdi
Commits
975e3266
Commit
975e3266
authored
Apr 14, 2014
by
Thomas Jahns
🤸
Browse files
Change model unpack to force resource IDs.
parent
c507daa8
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/model.c
View file @
975e3266
...
...
@@ -60,15 +60,24 @@ void modelDefaultValue ( model_t *modelptr )
modelptr
->
name
=
NULL
;
}
static
model_t
*
modelNewEntry
(
void
)
static
model_t
*
modelNewEntry
(
cdiResH
resH
,
int
instID
,
int
modelgribID
,
const
char
*
name
)
{
model_t
*
modelptr
;
modelptr
=
(
model_t
*
)
xmalloc
(
sizeof
(
model_t
));
modelDefaultValue
(
modelptr
);
modelptr
->
self
=
reshPut
((
void
*
)
modelptr
,
&
modelOps
);
if
(
resH
==
CDI_UNDEFID
)
modelptr
->
self
=
reshPut
(
modelptr
,
&
modelOps
);
else
{
modelptr
->
self
=
resH
;
reshReplace
(
resH
,
modelptr
,
&
modelOps
);
}
modelptr
->
used
=
1
;
modelptr
->
instID
=
instID
;
modelptr
->
modelgribID
=
modelgribID
;
if
(
name
&&
*
name
)
modelptr
->
name
=
strdupx
(
name
);
return
(
modelptr
);
}
...
...
@@ -193,11 +202,7 @@ int modelDef(int instID, int modelgribID, const char *name)
modelInit
();
modelptr
=
modelNewEntry
();
modelptr
->
instID
=
instID
;
modelptr
->
modelgribID
=
modelgribID
;
if
(
name
&&
*
name
)
modelptr
->
name
=
strdupx
(
name
);
modelptr
=
modelNewEntry
(
CDI_UNDEFID
,
instID
,
modelgribID
,
name
);
return
modelptr
->
self
;
}
...
...
@@ -308,24 +313,29 @@ static void modelPackP(void * modelptr, void * buf, int size, int *position, voi
}
int
modelUnpack
(
void
*
buf
,
int
size
,
int
*
position
,
int
nspTarget
,
void
*
context
)
modelUnpack
(
void
*
buf
,
int
size
,
int
*
position
,
int
nspTarget
,
void
*
context
,
int
force_id
)
{
int
tempbuf
[
model_nints
];
int
modelID
;
char
*
name
=
NULL
;
char
*
name
;
serializeUnpack
(
buf
,
size
,
position
,
tempbuf
,
model_nints
,
DATATYPE_INT
,
context
);
if
(
tempbuf
[
3
]
!=
0
)
{
name
=
(
char
*
)
xmalloc
(
tempbuf
[
3
]);
serializeUnpack
(
buf
,
size
,
position
,
name
,
tempbuf
[
3
],
DATATYPE_TXT
,
context
);
}
modelID
=
modelDef
(
namespaceAdaptKey
(
tempbuf
[
1
],
nspTarget
),
tempbuf
[
2
],
name
);
else
{
name
=
""
;
}
int
targetID
=
namespaceAdaptKey
(
tempbuf
[
0
],
nspTarget
);
model_t
*
mp
=
modelNewEntry
(
force_id
?
targetID
:
CDI_UNDEFID
,
namespaceAdaptKey
(
tempbuf
[
1
],
nspTarget
),
tempbuf
[
2
],
name
);
if
(
tempbuf
[
3
]
!=
0
)
free
(
name
);
// FIXME: this should work, once all types are transferred
//assert(modelID == tempbuf[0]);
return
modelID
;
xassert
(
!
force_id
||
(
mp
->
self
==
namespaceAdaptKey
(
tempbuf
[
0
],
nspTarget
)));
return
mp
->
self
;
}
/*
...
...
src/model.h
View file @
975e3266
...
...
@@ -3,7 +3,7 @@
int
modelUnpack
(
void
*
buf
,
int
size
,
int
*
position
,
int
,
void
*
context
);
int
nspTarget
,
void
*
context
,
int
force_id
);
void
modelDefaultEntries
(
void
);
...
...
src/resource_unpack.c
View file @
975e3266
...
...
@@ -60,7 +60,7 @@ void reshUnpackResources(char * unpackBuffer, int unpackBufferSize,
break
;
case
MODEL
:
modelUnpack
(
unpackBuffer
,
unpackBufferSize
,
&
unpackBufferPos
,
nspTarget
,
context
);
nspTarget
,
context
,
1
);
break
;
case
STREAM
:
if
(
sizeAssociations
==
numAssociations
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment