Permalink
Browse files

get rid of memory leak in allocation of channelset_defaults

git-svn-id: http://svn.metadecks.org/libremix/trunk@337 e2d53364-18fc-0310-981e-b60a84739af0
  • Loading branch information...
1 parent c7314fb commit 1876b6f63393faaa71ca732e780d74a27eaf11e4 conrad committed Jan 30, 2006
Showing with 22 additions and 3 deletions.
  1. +15 −1 src/libremix/remix_channelset.c
  2. +2 −1 src/libremix/remix_context.c
  3. +2 −1 src/libremix/remix_private.h
  4. +3 −0 src/tests/noop.c
View
16 src/libremix/remix_channelset.c
@@ -33,7 +33,7 @@ CDSet * REMIX_MONO = RemixNone;
CDSet * REMIX_STEREO = RemixNone;
void
-remix_channelset_initialise_defaults (RemixEnv * env)
+remix_channelset_defaults_initialise (RemixEnv * env)
{
if (REMIX_MONO == NULL) {
REMIX_MONO = cd_set_new (env);
@@ -51,3 +51,17 @@ remix_channelset_initialise_defaults (RemixEnv * env)
return;
}
+
+void
+remix_channelset_defaults_destroy (RemixEnv * env)
+{
+ if (REMIX_MONO != NULL) {
+ cd_set_free (env, REMIX_MONO);
+ REMIX_MONO = NULL;
+ }
+
+ if (REMIX_STEREO != NULL) {
+ cd_set_free (env, REMIX_STEREO);
+ REMIX_STEREO = NULL;
+ }
+}
View
3 src/libremix/remix_context.c
@@ -40,6 +40,7 @@ remix_context_destroy (RemixEnv * env)
world->purging = 1;
/* XXX: remix_destroy_list (env, world->plugins); */
/* XXX: remix_destroy_list (env, world->bases); */
+ remix_channelset_defaults_destroy (env);
remix_free (ctx);
remix_free (world);
}
@@ -129,7 +130,7 @@ remix_init (void)
ctx->tempo = REMIX_DEFAULT_TEMPO;
env = remix_add_thread_context (ctx, world);
- remix_channelset_initialise_defaults (env);
+ remix_channelset_defaults_initialise (env);
ctx->channels = REMIX_MONO;
remix_plugin_initialise_defaults (env);
View
3 src/libremix/remix_private.h
@@ -285,7 +285,7 @@ RemixEnv * _remix_register_base (RemixEnv * env, RemixBase * base);
RemixEnv * _remix_unregister_base (RemixEnv * env, RemixBase * base);
/* remix_plugin */
-void remix_plugin_initialise_defaults (RemixEnv * env);
+void remix_plugin_defaults_initialise (RemixEnv * env);
/* remix_deck */
RemixTrack * _remix_deck_add_track (RemixEnv * env, RemixDeck * deck,
@@ -360,6 +360,7 @@ RemixCount remix_channel_mix (RemixEnv * env, RemixChannel * src,
/* remix_channelset */
void remix_channelset_initialise_defaults (RemixEnv * env);
+void remix_channelset_defaults_destroy (RemixEnv * env);
/* remix_chunk */
RemixChunk * remix_chunk_new (RemixEnv * env, RemixCount start_index,
View
3 src/tests/noop.c
@@ -29,5 +29,8 @@ main (int argc, char ** argv)
INFO ("+ Creating new RemixEnv");
env = remix_init ();
+ INFO ("+ Purging RemixEnv");
+ remix_purge (env);
+
return 0;
}

0 comments on commit 1876b6f

Please sign in to comment.