On segunda-feira, 2 de abril de 2018 20:47:26 PDT Maloor, Kishen wrote:
> Consequently, just modifying oc_rep to allocate them dynamically
> wouldn’t make the APIs thread-safe.

You shouldn't allocate TinyCBOR objects dynamically. The line that Uze 

  CborEncoder new_rep = oc_rep_create_root_object(); 

Would actually work, by returning the object by value and storing it on the 
stack. It's all the next line that would have a problem:

  oc_process_baseline_interface(new_rep, request->resource);

The & is missing, to pass the CborEncoder object by pointer.

That said, what would oc_rep_create_root_object() do? Because if it's a sub-
encoder of a global encoder, then making this change does not help at all and 
thread-safety is not achieved. You need the outermost CborEncoder as well as 
the buffer it's writing to, to be present in the encoding function.

PS: I have a pending task but no time to complete the implementation of 
CborEncoder writing to platform-specific chunked buffers.

Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center

iotivity-dev mailing list

Reply via email to