Re: Solving a Memory Leak Problem...
- From: Jan Kratochvil <rcpt-orbit-list AT gnome org jankratochvil net>
- To: Craig McDaniel <craigm nplus1 net>
- Cc: orbit-list gnome org
- Subject: Re: Solving a Memory Leak Problem...
- Date: Wed, 5 Nov 2003 20:56:17 +0100
Hi,
On Wed, 05 Nov 2003 20:28:33 +0100, Craig McDaniel wrote:
...
> table = Table__alloc();
> table->_buffer = Table_allocbuf(2); // 2 rows
> table->_length = 2;
> table->_maximum = 5;
There should be:
table->buffer = Table_allocbuf (table->_maximum);
_length: Specifies the number of filled items.
_maximum: Specifies the number of allocated items.
...
> Pretty simple, but obviously if this function is called multiple times
> by the client, the allocated memory is not released. What is the best
> solution for freeing this memory after it has been passed to the
> client?
CORBA_sequence_set_release (seq, CORBA_TRUE);
or
seq->_release = CORBA_TRUE
or
CORBA_*_set_release (ptr, CORBA_TRUE);
> Also, I can't find much documentation on programming multi-dimensional
> sequences. Are there any best practices I should know about, or is the
> above code acceptable (except for the leak problem)?
What about
table = ORBit_sequence_alloc (TC_Table, rows * columns);
where you can use cells addressing by
table->_buffer[(row * columns) + column]
You would have to reshuffle the items in the case of changing the table size
dynamically by ORBit_sequence_set_size() but I do not expect you need to do it.
Regards,
Lace
--
Jan Kratochvil; Captive: free r/w NTFS Filesystem; http://www.jankratochvil.net/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]