From c3744b6736ce45c1c700b7f026fb0acfb0069a6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Wed, 7 May 2008 17:49:47 +0200 Subject: Use asprintf() rather than malloc() + sprintf(). Using asprintf() instead of malloc() + sprintf() reduces the lines of code in xine-lib (moving the allocation to the C library or asprintf replacement), makes it safer to access the string and can also improve performance whenever the value returned by a function was used as parameter, as before it had to run the function twice in almost every case (once for strlen(), once for sprintf()). --- src/xine-engine/osd.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src/xine-engine/osd.c') diff --git a/src/xine-engine/osd.c b/src/xine-engine/osd.c index 5de0de2cb..ac3c2bb92 100644 --- a/src/xine-engine/osd.c +++ b/src/xine-engine/osd.c @@ -1410,7 +1410,6 @@ static void osd_preload_fonts (osd_renderer_t *this, char *path) { if( p ) { osd_font_t *font; - char *pathname; *p++ = '\0'; font = calloc(1, sizeof(osd_font_t) ); @@ -1421,9 +1420,7 @@ static void osd_preload_fonts (osd_renderer_t *this, char *path) { lprintf("font '%s' size %d is preloaded\n", font->name, font->size); - pathname = malloc(strlen(path) + strlen(entry->d_name) + 2); - sprintf (pathname, "%s/%s", path, entry->d_name); - font->filename = pathname; + asprintf (&font->filename, "%s/%s", path, entry->d_name); font->next = this->fonts; this->fonts = font; -- cgit v1.2.3