Skip to content

Commit 83706c0

Browse files
committed
opal/datatype: do not set optimized description if unused
Thanks George for the guidance Refs #3438 Signed-off-by: Gilles Gouaillardet <gilles@rist.or.jp>
1 parent 3b99149 commit 83706c0

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

opal/datatype/opal_datatype_clone.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
* All rights reserved.
1313
* Copyright (c) 2009 Sun Microsystems, Inc. All rights reserved.
1414
* Copyright (c) 2009 Oak Ridge National Labs. All rights reserved.
15+
* Copyright (c) 2017 Research Organization for Information Science
16+
* and Technology (RIST). All rights reserved.
1517
* $COPYRIGHT$
1618
*
1719
* Additional copyrights may follow
@@ -61,6 +63,8 @@ int32_t opal_datatype_clone( const opal_datatype_t * src_type, opal_datatype_t *
6163
dest_type->opt_desc.used = src_type->opt_desc.used;
6264
memcpy( dest_type->opt_desc.desc, src_type->opt_desc.desc, desc_length * sizeof(dt_elem_desc_t) );
6365
}
66+
} else {
67+
assert(NULL == dest_type->opt_desc.desc);
6468
}
6569
}
6670
dest_type->id = src_type->id; /* preserve the default id. This allow us to

opal/datatype/opal_datatype_optimize.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,12 @@ opal_datatype_optimize_short( opal_datatype_t* pData,
247247
}
248248
/* cleanup the stack */
249249
pTypeDesc->used = nbElems - 1; /* except the last fake END_LOOP */
250+
if (OPAL_UNLIKELY(0 == pTypeDesc->used)) {
251+
/* optimized description is not gonna be used, so free it */
252+
free(pTypeDesc->desc);
253+
pTypeDesc->desc = NULL;
254+
pTypeDesc->length = 0;
255+
}
250256
free(pOrigStack);
251257
return OPAL_SUCCESS;
252258
}

0 commit comments

Comments
 (0)