Changeset 675

Show
Ignore:
Timestamp:
12/17/09 21:49:22 (2 years ago)
Author:
erikd
Message:

Fix memory leak (each pulse_open() was allocating memory which was never
freed) and switch to static data for sw_handles.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sweep/trunk/src/driver_pulseaudio.c

    r674 r675  
    4747#include <pulse/error.h> 
    4848 
    49 sw_handle * handle_in, * handle_out = NULL; 
     49static sw_handle handle_ro = { 
     50 0, -1, 0, 0, NULL 
     51}; 
     52 
     53static sw_handle handle_wo = { 
     54 0, -1, 0, 0, NULL 
     55}; 
     56 
     57static sw_handle handle_rw = { 
     58 0, -1, 0, 0, NULL 
     59}; 
    5060 
    5161static GList * 
     
    6272pulse_open (int monitoring, int flags) 
    6373{ 
    64   sw_handle * handle = NULL
     74  sw_handle * handle = &handle_rw
    6575 
    6676  if (flags == O_RDONLY) { 
    67     handle = handle_in
     77    handle = &handle_ro
    6878  } else if (flags == O_WRONLY) { 
    69     handle = handle_out; 
    70   } else { 
    71     return NULL; 
    72   } 
    73  
    74   handle = g_malloc0 (sizeof (sw_handle)); 
     79    handle = &handle_wo; 
     80  } 
    7581 
    7682  handle->driver_flags = flags;