Memory management



Hello,

is there a way to get the server-side to automatically free data
structures once they have been passed to the client?

On the server-side, I am allocating Corba sequences, filling them with
data, and returning them. Example (simplified):

  retval = CORBA_sequence_CORBA_octet__alloc();

  retval->_maximum = size;
  retval->_length = size;
  retval->_buffer = CORBA_sequence_CORBA_octet_allocbuf(size);

  memcpy(retval->_buffer, image, (long)size);

  free(image);

  retval->_release = TRUE;

  return retval;

On the client-side, I am receiving the sequence, using it, and finally
releasing the object. Example (simlified):

  client = CORBA_ORB_string_to_object(orb, argv[1], &ev);

  res = CorbaModule_Interface_Method(client);

  for (i = res->_length; i > 0; --i)
          ... res->_buffer[i] ... /* something */

  CORBA_Object_release(client, &ev);

  exit(0);

Do I need to keep a global reference to the sequence at the server 
side and write another method that frees the sequence once it is 
called from the client? Is there no better way, accommodating naive
clients that cleans up by terminating its process?

This should be basic stuff. Yet I have failed to find any documention
on it. Could you give me some pointers to the right places? Or, even
better, perhaps point out what I have neglected to do?

Best Regards /Selander
-- 
Anders Selander   Centre for Parallel Computers   selander@pdc.kth.se
Programmer        Royal Institute of Technology   +46 (0)8  790 72 11
                  SE-100 44  STOCKHOLM, SWEDEN    +46 (0)70 266 29 67



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]