From ae5eec3e2f3ae9c29176c58f4611a256b36ae211 Mon Sep 17 00:00:00 2001 From: Ralph Castain Date: Thu, 5 Jun 2014 14:49:37 +0000 Subject: [PATCH] Minor tweaks to the pack/unpack routines This commit was SVN r31954. --- opal/dss/dss_pack.c | 8 ++++++-- opal/dss/dss_unpack.c | 11 +++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/opal/dss/dss_pack.c b/opal/dss/dss_pack.c index 8878c9a5c9..22d42fb87b 100644 --- a/opal/dss/dss_pack.c +++ b/opal/dss/dss_pack.c @@ -822,8 +822,12 @@ int opal_dss_pack_buffer_contents(opal_buffer_t *buffer, const void *src, return ret; } /* pack the bytes */ - if (OPAL_SUCCESS != (ret = opal_dss_pack_byte(buffer, ptr[i]->base_ptr, ptr[i]->bytes_used, OPAL_BYTE))) { - return ret; + if (0 < ptr[i]->bytes_used) { + if (OPAL_SUCCESS != (ret = opal_dss_pack_byte(buffer, ptr[i]->base_ptr, ptr[i]->bytes_used, OPAL_BYTE))) { + return ret; + } + } else { + ptr[i]->base_ptr = NULL; } } return OPAL_SUCCESS; diff --git a/opal/dss/dss_unpack.c b/opal/dss/dss_unpack.c index 509f0f553d..87949c3686 100644 --- a/opal/dss/dss_unpack.c +++ b/opal/dss/dss_unpack.c @@ -1063,16 +1063,15 @@ int opal_dss_unpack_buffer_contents(opal_buffer_t *buffer, void *dest, if (OPAL_SUCCESS != (ret = opal_dss_unpack_sizet(buffer, &nbytes, &m, OPAL_SIZE))) { return ret; } + m = nbytes; /* setup the buffer's data region */ if (0 < nbytes) { ptr[i]->base_ptr = (char*)malloc(nbytes); + /* unpack the bytes */ + if (OPAL_SUCCESS != (ret = opal_dss_unpack_byte(buffer, ptr[i]->base_ptr, &m, OPAL_BYTE))) { + return ret; + } } - /* unpack the bytes */ - m=nbytes; - if (OPAL_SUCCESS != (ret = opal_dss_unpack_byte(buffer, ptr[i]->base_ptr, &m, OPAL_BYTE))) { - return ret; - } - /* fill-in the metadata */ ptr[i]->pack_ptr = ptr[i]->base_ptr + m; ptr[i]->unpack_ptr = ptr[i]->base_ptr; ptr[i]->bytes_allocated = nbytes;