From a87b60337712543a6f715b45c80affbdc5ba520a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Tue, 18 Dec 2007 21:53:57 +0100 Subject: Use asprintf where possible. --- src/input/librtsp/rtsp.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/input/librtsp/rtsp.c b/src/input/librtsp/rtsp.c index 236dbc41e..b6dad6a31 100644 --- a/src/input/librtsp/rtsp.c +++ b/src/input/librtsp/rtsp.c @@ -21,6 +21,8 @@ * *not* RFC 2326 compilant yet. */ +#include + #include #include #include @@ -294,8 +296,7 @@ int rtsp_request_options(rtsp_t *s, const char *what) { buf=strdup(what); } else { - buf = malloc(sizeof(char)*(strlen(s->host)+16)); - sprintf(buf,"rtsp://%s:%i", s->host, s->port); + asprintf(&buf,"rtsp://%s:%i", s->host, s->port); } rtsp_send_request(s,"OPTIONS",buf); free(buf); @@ -311,8 +312,7 @@ int rtsp_request_describe(rtsp_t *s, const char *what) { buf=strdup(what); } else { - buf = malloc(sizeof(char)*(strlen(s->host)+strlen(s->path)+16)); - sprintf(buf,"rtsp://%s:%i/%s", s->host, s->port, s->path); + asprintf(&buf,"rtsp://%s:%i/%s", s->host, s->port, s->path); } rtsp_send_request(s,"DESCRIBE",buf); free(buf); @@ -335,8 +335,7 @@ int rtsp_request_setparameter(rtsp_t *s, const char *what) { buf=strdup(what); } else { - buf = malloc(sizeof(char)*(strlen(s->host)+strlen(s->path)+16)); - sprintf(buf,"rtsp://%s:%i/%s", s->host, s->port, s->path); + asprintf(&buf,"rtsp://%s:%i/%s", s->host, s->port, s->path); } rtsp_send_request(s,"SET_PARAMETER",buf); free(buf); @@ -352,8 +351,7 @@ int rtsp_request_play(rtsp_t *s, const char *what) { buf=strdup(what); } else { - buf = malloc(sizeof(char)*(strlen(s->host)+strlen(s->path)+16)); - sprintf(buf,"rtsp://%s:%i/%s", s->host, s->port, s->path); + asprintf(&buf,"rtsp://%s:%i/%s", s->host, s->port, s->path); } rtsp_send_request(s,"PLAY",buf); free(buf); @@ -402,8 +400,7 @@ int rtsp_read_data(rtsp_t *s, void *buffer_gen, unsigned int size) { } /* lets make the server happy */ rtsp_put(s, "RTSP/1.0 451 Parameter Not Understood"); - rest = malloc(sizeof(char)*17); - sprintf(rest,"CSeq: %u", seq); + asprintf(&rest,"CSeq: %u", seq); rtsp_put(s, rest); free(rest); rtsp_put(s, ""); -- cgit v1.2.3