Is ws.GetIntMemory() thread safe?

@dale, @stevebaer,

I am using ws.GetIntMemory() in my C++ DLL inside a parallel_for_each block. It seems to work but I just want to make sure that it is a thread-safe alternative to using new for memory allocation. It eliminates the need for manual removal of memory allocated by new and has many more scoping possibilities than make_unique<>.

It is used in several places in opennurbs_mesh.cpp but none of them are in a parallel block. Here is one example:

  ON_Workspace ws;
  int* vfcount = ws.GetIntMemory( vcount );
  memset ( vfcount, 0, vcount*sizeof(*vfcount) );

Regards,
Terry.

Hi @Terry_Chappell,

I don’t know of any instances in core Rhino were we do this. But don’t see why it wouldn’t work.

ON_Workspace is a stack-based memory helper - a wrapper around onmalloc and onfree.

ON_Workspace is not thread safe.

– Dale