Skip to content
Snippets Groups Projects
Commit 5ae93b17 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

institutInq(): allocate ip_ref on the stack.

parent 3d2fc809
No related branches found
No related tags found
No related merge requests found
Pipeline #9516 failed
......@@ -125,8 +125,8 @@ struct instLoc
static enum cdiApplyRet
findInstitute(int id, void *res, void *data)
{
institute_t * ip1 = ((struct instLoc *)data)->ip;
institute_t * ip2 = (institute_t*) res;
institute_t *ip1 = ((struct instLoc *)data)->ip;
institute_t *ip2 = (institute_t*) res;
if (ip2->used && !instituteCompareKernel(ip1, ip2))
{
((struct instLoc *)data)->id = id;
......@@ -139,19 +139,17 @@ findInstitute(int id, void *res, void *data)
int institutInq(int center, int subcenter, const char *name, const char *longname)
{
institute_t * ip_ref = (institute_t *) Malloc(sizeof (*ip_ref));
ip_ref->self = CDI_UNDEFID;
ip_ref->used = 0;
ip_ref->center = center;
ip_ref->subcenter = subcenter;
ip_ref->name = name && name[0] ? (char *)name : NULL;
ip_ref->longname = longname && longname[0] ? (char *)longname : NULL;
struct instLoc state = { .ip = ip_ref, .id = CDI_UNDEFID };
institute_t ip_ref;
ip_ref.self = CDI_UNDEFID;
ip_ref.used = 0;
ip_ref.center = center;
ip_ref.subcenter = subcenter;
ip_ref.name = (name && name[0]) ? (char *)name : NULL;
ip_ref.longname = (longname && longname[0]) ? (char *)longname : NULL;
struct instLoc state = { .ip = &ip_ref, .id = CDI_UNDEFID };
cdiResHFilterApply(&instituteOps, findInstitute, &state);
Free(ip_ref);
return state.id;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment