bu5hm4n pushed a commit to branch master.

http://git.enlightenment.org/apps/extra.git/commit/?id=b04e0fcd5d1dc867722b857683c408687cd045ac

commit b04e0fcd5d1dc867722b857683c408687cd045ac
Author: Marcel Hollerbach <[email protected]>
Date:   Mon Jan 9 22:22:28 2017 +0100

    extra: use strbuf
    
    the other calculation was a bit rough to read. And strbuf handles that 
better.
---
 src/lib/extra.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/lib/extra.c b/src/lib/extra.c
index cdc2f81..b2e8f16 100644
--- a/src/lib/extra.c
+++ b/src/lib/extra.c
@@ -445,13 +445,17 @@ extra_theme_preview_download(Extra_Progress *progress, 
Extra_Theme *theme)
 EAPI char *
 extra_theme_download_url_get(Extra_Theme *theme)
 {
-   const char *pattern = "http://"; HOSTNAME "/themes/%s-%d.edj";
+   Eina_Strbuf *buf;
    char *url;
 
    EINA_SAFETY_ON_NULL_RETURN_VAL(theme, NULL);
 
-   url = malloc((strlen(pattern) + strlen(theme->id) - 1 + 
(int)(log10(theme->version))) * sizeof(char));
-   sprintf(url, pattern, theme->id, theme->version);
+   buf = eina_strbuf_new();
+   eina_strbuf_append(buf, "http://"; HOSTNAME "/themes/");
+   eina_strbuf_append_printf(buf, "%s-%d.edj", theme->id, theme->version);
+
+   url = eina_strbuf_string_steal(buf);
+   eina_strbuf_free(url);
 
    return url;
 }

-- 


Reply via email to