[xiph-cvs] cvs commit: icecast/src client.c client.h format_mp3.c

Karl Heyes karl at xiph.org
Sun Feb 29 06:38:18 PST 2004



karl        04/02/29 09:38:18

  Modified:    src      client.c client.h format_mp3.c
  Log:
  free up any per-client format specific resources, fixes a small memory
  leak with mp3 streams

Revision  Changes    Path
1.14      +4 -0      icecast/src/client.c

Index: client.c
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/client.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- client.c	3 Feb 2004 00:48:02 -0000	1.13
+++ client.c	29 Feb 2004 14:38:15 -0000	1.14
@@ -63,6 +63,10 @@
     while ((refbuf = refbuf_queue_remove(&client->queue)))
         refbuf_release(refbuf);
 
+    /* we need to free client specific format data (if any) */
+    if (client->free_client_data)
+        client->free_client_data (client);
+
     free(client->username);
 
     free(client);

<p><p>1.11      +3 -0      icecast/src/client.h

Index: client.h
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/client.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- client.h	29 Jan 2004 01:02:06 -0000	1.10
+++ client.h	29 Feb 2004 14:38:15 -0000	1.11
@@ -42,6 +42,9 @@
 
     /* Format-handler-specific data for this client */
     void *format_data;
+
+    /* function to call to release format specific resources */
+    void (*free_client_data)(struct _client_tag *client);
 } client_t;
 
 client_t *client_create(connection_t *con, http_parser_t *parser);

<p><p>1.35      +10 -0     icecast/src/format_mp3.c

Index: format_mp3.c
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/format_mp3.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- format_mp3.c	26 Feb 2004 10:39:56 -0000	1.34
+++ format_mp3.c	29 Feb 2004 14:38:15 -0000	1.35
@@ -59,6 +59,7 @@
 static refbuf_queue_t *format_mp3_get_predata(format_plugin_t *self);
 static void *format_mp3_create_client_data(format_plugin_t *self,
         source_t *source, client_t *client);
+static void free_mp3_client_data (client_t *client);
 static int format_mp3_write_buf_to_client(format_plugin_t *self,
         client_t *client, unsigned char *buf, int len);
 static void format_mp3_send_headers(format_plugin_t *self, 
@@ -394,6 +395,7 @@
 
     data->interval = ICY_METADATA_INTERVAL;
     data->offset = 0;
+    client->free_client_data = free_mp3_client_data;
 
     metadata = httpp_getvar(client->parser, "icy-metadata");
     if(metadata)
@@ -402,6 +404,14 @@
     return data;
 }
 
+
+static void free_mp3_client_data (client_t *client)
+{
+    free (client->format_data);
+    client->format_data = NULL;
+}
+
+
 static void format_mp3_send_headers(format_plugin_t *self,
         source_t *source, client_t *client)
 {

<p><p>--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.



More information about the commits mailing list