18.2.178. PMIx_Byte_object_load

PMIx_Byte_object_load — Load a data buffer into a pmix_byte_object_t(5) structure.

18.2.178.1. SYNOPSIS

#include <pmix.h>

void PMIx_Byte_object_load(pmix_byte_object_t *b,
                           char *d, size_t sz);

18.2.178.1.1. Python Syntax

No Python equivalent

18.2.178.2. INPUT PARAMETERS

  • b: Pointer to the pmix_byte_object_t(5) structure into which the data is to be loaded.

  • d: Pointer to the data buffer to load.

  • sz: Size, in bytes, of the data buffer.

18.2.178.3. DESCRIPTION

Load a data buffer into a pmix_byte_object_t by directly assigning the object’s bytes field to d and its size field to sz. No copy is made — the byte object simply takes ownership of the pointer d that the caller supplied.

Because ownership transfers, the caller must not free d after loading it; the memory will be released when the byte object is subsequently destructed or freed. The target structure b should be empty (freshly constructed) before loading, since any existing payload it holds is overwritten without being freed.

18.2.178.4. RETURN VALUE

PMIx_Byte_object_load returns no value (void).

18.2.178.5. NOTES

The convenience macro PMIX_BYTE_OBJECT_LOAD wraps this function and additionally resets the caller’s source pointer to NULL and the source size to zero, reflecting the transfer of ownership.

18.2.178.6. EXAMPLES

Load an allocated buffer into a byte object:

pmix_byte_object_t bo;
char *data;
size_t len;

PMIx_Byte_object_construct(&bo);
data = strdup("payload");
len = strlen(data) + 1;
PMIx_Byte_object_load(&bo, data, len);
/* 'bo' now owns 'data'; do not free 'data' directly */
PMIx_Byte_object_destruct(&bo);