[Mochi-devel] Serializing raw buffers in mercury

Philip Davis philip.e.davis at rutgers.edu
Thu Feb 6 11:53:55 CST 2020


Great, thanks for the example! One question: is memory being allocated for the second argument to hg_proc_* before it is called? I was thinking that on a DECODE operation that argument would be uninitialized, but in the KV example you sent, arg is being cast to a pointer to a kv_data_t struct, which is then dereferenced. Is it doing a malloc(sizeof(kv_data_t) or similar before the call?

> On Feb 6, 2020, at 12:45 PM, Dorier, Matthieu <mdorier at anl.gov> wrote:
> 
> Hi Philip,
> 
> Here is an example of how it's done in one of our services:
> https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fxgitlab.cels.anl.gov%2Fsds%2Fsds-keyval%2Fblob%2Fmaster%2Fsrc%2Fsdskv-rpc-types.h%23L18&data=02%7C01%7Cphilip.e.davis%40rutgers.edu%7C351c038a399343ce325f08d7ab2c5d16%7Cb92d2b234d35447093ff69aca6632ffe%7C1%7C0%7C637166079340260872&sdata=iDmA6C9cRWq5dT%2BHMyHMrJMqHpsCN%2BlQnQZVKrzl0%2Bw%3D&reserved=0
> 
> Thanks,
> 
> Matthieu
> 
> On 06/02/2020, 10:12, "mochi-devel on behalf of Philip Davis" <mochi-devel-bounces at lists.mcs.anl.gov on behalf of philip.e.davis at rutgers.edu> wrote:
> 
>    Hello,
> 
>    I have a need to serialize a simple raw buffer (void * and length.) I’m looking at the “serializing complex data structures” page on the Margo documentation, and I want to make sure I’m doing this right. Should I be writing an hg_proc_* function that serializes the hg_size_t and uses hg_proc_raw to copy the buffer, or is there some existing hg_proc_* function I can leverage to encode/decode the buffer/length pair in a single call? It doesn’t look to me like hg_proc_raw can do this, since the length is copied by value.
> 
>    Thanks,
>    Philip
>    _______________________________________________
>    mochi-devel mailing list
>    mochi-devel at lists.mcs.anl.gov
>    https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.mcs.anl.gov%2Fmailman%2Flistinfo%2Fmochi-devel&data=02%7C01%7Cphilip.e.davis%40rutgers.edu%7C351c038a399343ce325f08d7ab2c5d16%7Cb92d2b234d35447093ff69aca6632ffe%7C1%7C0%7C637166079340260872&sdata=gfuDshPyAW4dDTzKbHvhmU7axGV6PpUdJsdtgtP3hSU%3D&reserved=0
>    https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.mcs.anl.gov%2Fresearch%2Fprojects%2Fmochi&data=02%7C01%7Cphilip.e.davis%40rutgers.edu%7C351c038a399343ce325f08d7ab2c5d16%7Cb92d2b234d35447093ff69aca6632ffe%7C1%7C0%7C637166079340260872&sdata=rbdmImmIV6kN6tY5CYmJ9XAIaNpn77Dz33Z8ivJv1Cs%3D&reserved=0
> 
> 



More information about the mochi-devel mailing list