diff options
author | Diego 'Flameeyes' Pettenò <flameeyes@gmail.com> | 2007-12-18 21:52:04 +0100 |
---|---|---|
committer | Diego 'Flameeyes' Pettenò <flameeyes@gmail.com> | 2007-12-18 21:52:04 +0100 |
commit | a365222f0200a3f5437a601b06791eb7c03ff4e3 (patch) | |
tree | 5a15220fad17967a7fe427d9455ce7737808ab7e /src | |
parent | be4a142d17fdcf23a79b02c45064f98141468dcd (diff) | |
download | xine-lib-a365222f0200a3f5437a601b06791eb7c03ff4e3.tar.gz xine-lib-a365222f0200a3f5437a601b06791eb7c03ff4e3.tar.bz2 |
Use variable-sized arrays rather than allocated buffers.
Diffstat (limited to 'src')
-rw-r--r-- | src/input/librtsp/rtsp.c | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/src/input/librtsp/rtsp.c b/src/input/librtsp/rtsp.c index a44d0e8e1..236dbc41e 100644 --- a/src/input/librtsp/rtsp.c +++ b/src/input/librtsp/rtsp.c @@ -103,8 +103,7 @@ const char rtsp_protocol_version[]="RTSP/1.0"; */ static char *rtsp_get(rtsp_t *s) { - - char *buffer = malloc(BUF_SIZE); + char buffer[BUF_SIZE]; char *string = NULL; if ( _x_io_tcp_read_line(s->stream, s->s, buffer, BUF_SIZE) >= 0 ) { @@ -112,7 +111,6 @@ static char *rtsp_get(rtsp_t *s) { string = strdup( buffer ); } - free(buffer); return string; } @@ -124,7 +122,7 @@ static char *rtsp_get(rtsp_t *s) { static void rtsp_put(rtsp_t *s, const char *string) { int len=strlen(string); - char *buf = malloc(sizeof(char)*len+2); + char buf[len+2]; lprintf(">> '%s'", string); @@ -135,8 +133,6 @@ static void rtsp_put(rtsp_t *s, const char *string) { _x_io_tcp_write(s->stream, s->s, buf, len+2); lprintf("done.\n"); - - free(buf); } /* @@ -171,13 +167,11 @@ static int rtsp_get_code(rtsp_t *s, const char *string) { static void rtsp_send_request(rtsp_t *s, const char *type, const char *what) { char **payload=s->scheduled; - char *buf; - - buf = malloc(strlen(type)+strlen(what)+strlen(rtsp_protocol_version)+3); + char buf[strlen(type)+strlen(what)+strlen(rtsp_protocol_version)+3]; sprintf(buf,"%s %s %s",type, what, rtsp_protocol_version); rtsp_put(s,buf); - free(buf); + if (payload) while (*payload) { rtsp_put(s,*payload); @@ -199,11 +193,9 @@ static void rtsp_schedule_standard(rtsp_t *s) { rtsp_schedule_field(s, tmp); if (s->session) { - char *buf; - buf = malloc(strlen(s->session)+15); + char buf[strlen(s->session)+15]; sprintf(buf, "Session: %s", s->session); rtsp_schedule_field(s, buf); - free(buf); } } /* @@ -241,14 +233,13 @@ static int rtsp_get_answers(rtsp_t *s) { } } if (!strncasecmp(answer,"Server:",7)) { - char *buf = xine_xmalloc(strlen(answer)); + char buf[strlen(answer)]; sscanf(answer,"%*s %s",buf); if (s->server) free(s->server); s->server=strdup(buf); - free(buf); } if (!strncasecmp(answer,"Session:",8)) { - char *buf = xine_xmalloc(strlen(answer)); + char buf[strlen(answer)]; sscanf(answer,"%*s %s",buf); if (s->session) { if (strcmp(buf, s->session)) { @@ -263,7 +254,6 @@ static int rtsp_get_answers(rtsp_t *s) { s->session=strdup(buf); } - free(buf); } *answer_ptr=answer; answer_ptr++; |