[xiph-commits] r16820 - trunk/vorbis-tools/ogg123

xiphmont at svn.xiph.org xiphmont at svn.xiph.org
Tue Jan 26 03:08:25 PST 2010


Author: xiphmont
Date: 2010-01-26 03:08:25 -0800 (Tue, 26 Jan 2010)
New Revision: 16820

Modified:
   trunk/vorbis-tools/ogg123/callbacks.c
   trunk/vorbis-tools/ogg123/ogg123.c
Log:
Don't expect to call an atexit 'destroy everything' handler in a threaded 
app.  I mean, seriously.



Modified: trunk/vorbis-tools/ogg123/callbacks.c
===================================================================
--- trunk/vorbis-tools/ogg123/callbacks.c	2010-01-26 11:07:15 UTC (rev 16819)
+++ trunk/vorbis-tools/ogg123/callbacks.c	2010-01-26 11:08:25 UTC (rev 16820)
@@ -124,12 +124,12 @@
 {
   audio_reopen_arg_t *arg;
 
-  if ( (arg = malloc(sizeof(audio_reopen_arg_t))) == NULL ) {
+  if ( (arg = calloc(1,sizeof(audio_reopen_arg_t))) == NULL ) {
     status_error(_("ERROR: Out of memory in new_audio_reopen_arg().\n"));
     exit(1);
   }
 
-  if ( (arg->format = malloc(sizeof(audio_format_t))) == NULL ) {
+  if ( (arg->format = calloc(1,sizeof(audio_format_t))) == NULL ) {
     status_error(_("ERROR: Out of memory in new_audio_reopen_arg().\n"));
     exit(1);
   }
@@ -175,7 +175,7 @@
 {
   print_statistics_arg_t *arg;
 
-  if ( (arg = malloc(sizeof(print_statistics_arg_t))) == NULL ) {
+  if ( (arg = calloc(1,sizeof(print_statistics_arg_t))) == NULL ) {
     status_error(_("Error: Out of memory in new_print_statistics_arg().\n"));
     exit(1);
   }
@@ -234,7 +234,7 @@
 {
   status_message_arg_t *arg;
 
-  if ( (arg = malloc(sizeof(status_message_arg_t))) == NULL ) {
+  if ( (arg = calloc(1,sizeof(status_message_arg_t))) == NULL ) {
     status_error(_("ERROR: Out of memory in new_status_message_arg().\n"));
     exit(1);
   }
@@ -280,7 +280,7 @@
   /* Preformat the string and allocate space for it.  This code taken
      straight from the vsnprintf() man page.  We do this here because
      we might need to reinit ap several times. */
-  if ((sm_arg->message = malloc (size)) == NULL) {
+  if ((sm_arg->message = calloc (size,1)) == NULL) {
     status_error(_("Error: Out of memory in decoder_buffered_metadata_callback().\n"));
     exit(1);
   }
@@ -336,7 +336,7 @@
   /* Preformat the string and allocate space for it.  This code taken
      straight from the vsnprintf() man page.  We do this here because
      we might need to reinit ap several times. */
-  if ((sm_arg->message = malloc (size)) == NULL) {
+  if ((sm_arg->message = calloc (size,1)) == NULL) {
     status_error(_("ERROR: Out of memory in decoder_buffered_metadata_callback().\n"));
     exit(1);
   }

Modified: trunk/vorbis-tools/ogg123/ogg123.c
===================================================================
--- trunk/vorbis-tools/ogg123/ogg123.c	2010-01-26 11:07:15 UTC (rev 16819)
+++ trunk/vorbis-tools/ogg123/ogg123.c	2010-01-26 11:08:25 UTC (rev 16820)
@@ -53,7 +53,6 @@
 
 extern int exit_status; /* from status.c */
 
-void exit_cleanup ();
 void play (char *source_string);
 
 #define PRIMAGIC (2*2*2*2*3*3*3*5*7)
@@ -64,7 +63,7 @@
 
 ogg123_options_t options;
 stat_format_t *stat_format;
-buf_t *audio_buffer;
+buf_t *audio_buffer=NULL;
 
 audio_play_arg_t audio_play_arg;
 
@@ -466,7 +465,6 @@
 
   /* Setup signal handlers and callbacks */
 
-  ATEXIT (exit_cleanup);
   signal (SIGINT, signal_handler);
   signal (SIGTSTP, signal_handler);
   signal (SIGCONT, signal_handler);
@@ -505,6 +503,13 @@
   playlist_array_destroy(playlist_array, items);
   status_deinit();
 
+  if (audio_buffer != NULL) {
+    buffer_destroy (audio_buffer);
+    audio_buffer = NULL;
+  }
+
+  ao_onexit (options.devices);
+
   exit (exit_status);
 }
 
@@ -747,14 +752,3 @@
     exit (exit_status);
 }
 
-
-void exit_cleanup ()
-{
-
-  if (audio_buffer != NULL) {
-    buffer_destroy (audio_buffer);
-    audio_buffer = NULL;
-  }
-
-  ao_onexit (options.devices);
-}



More information about the commits mailing list