On Sat, Sep 5, 2009 at 3:38 AM, Christian<krampenschiesser(a)freenet.de> wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
As I'm new to smart pointers and memory management in C++ I have a short
question on this topic.
I'm now using the following code to traverse the devices and their ports:
snd_seq_client_info_t *clientInfo = 0;
snd_seq_port_info_t *portInfo = 0;
snd_seq_client_info_malloc(&clientInfo);
snd_seq_port_info_malloc(&portInfo);
shared_ptr<snd_seq_client_info_t> clientInfoMemoryHandler(clientInfo,
snd_seq_client_info_free);
shared_ptr<snd_seq_port_info_t> portInfoMemoryHandler(portInfo,
snd_seq_port_info_free);
.
.
.
snd_seq_port_info_set_client( portInfo,
snd_seq_client_info_get_client(clientInfo ) );
snd_seq_port_info_set_port( portInfo, -1 );
while ( snd_seq_query_next_port( seq, portInfo ) >= 0 ) {
string portName = snd_seq_port_info_get_name( portInfo );
unsigned int capability = snd_seq_port_info_get_capability( portInfo );
.
.
.
Well the cleanUp methods are called at block-leaving.
I'm only a bit curious because after giving portInfo and clientInfo to
the shared_ptr for cleanup management I have to use them for all the
alsa queries.
But since I'm not using malloc and free in these queries everything is
ok, isn't it?
I'm unclear why you are attempting to use C++ shared ptr's with ALSA's
very clearly C-style explicit memory management of various opaque data
objects. What are you attempting to do?