Gitweb links:

...log 
http://git.netsurf-browser.org/netsurf.git/shortlog/fb1d9862f993861a13224f80e0aaae696476fa05
...commit 
http://git.netsurf-browser.org/netsurf.git/commit/fb1d9862f993861a13224f80e0aaae696476fa05
...tree 
http://git.netsurf-browser.org/netsurf.git/tree/fb1d9862f993861a13224f80e0aaae696476fa05

The branch, master has been updated
       via  fb1d9862f993861a13224f80e0aaae696476fa05 (commit)
       via  47e47244a9dc397293dbf94c9f1e22f715b95ff4 (commit)
       via  c76b5ef4d548429b5ee3ee87ddd5d917431afd34 (commit)
      from  3ba50e85747d31deaa2c4c17950b46fc50019564 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commitdiff 
http://git.netsurf-browser.org/netsurf.git/commit/?id=fb1d9862f993861a13224f80e0aaae696476fa05
commit fb1d9862f993861a13224f80e0aaae696476fa05
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>

    data url handler: Keep nsurl to avoid copy.

diff --git a/content/fetchers/data.c b/content/fetchers/data.c
index b8710dd..7077dd9 100644
--- a/content/fetchers/data.c
+++ b/content/fetchers/data.c
@@ -41,7 +41,7 @@
 
 struct fetch_data_context {
        struct fetch *parent_fetch;
-       char *url;
+       nsurl *url;
        char *mimetype;
        char *data;
        size_t datalen;
@@ -85,14 +85,7 @@ static void *fetch_data_setup(struct fetch *parent_fetch, 
nsurl *url,
                return NULL;
                
        ctx->parent_fetch = parent_fetch;
-
-       /* TODO: keep as nsurl to avoid copy */
-       ctx->url = malloc(nsurl_length(url) + 1);
-       if (ctx->url == NULL) {
-               free(ctx);
-               return NULL;
-       }
-       memcpy(ctx->url, nsurl_access(url), nsurl_length(url) + 1);
+       ctx->url = nsurl_ref(url);
 
        RING_INSERT(ring, ctx);
        
@@ -108,7 +101,7 @@ static void fetch_data_free(void *ctx)
 {
        struct fetch_data_context *c = ctx;
 
-       free(c->url);
+       nsurl_unref(c->url);
        free(c->data);
        free(c->mimetype);
        RING_REMOVE(ring, c);
@@ -149,9 +142,9 @@ static bool fetch_data_process(struct fetch_data_context *c)
         * data must still be there.
         */
        
-       NSLOG(netsurf, INFO, "url: %.140s", c->url);
+       NSLOG(netsurf, INFO, "url: %.140s", nsurl_access(c->url));
        
-       if (strlen(c->url) < 6) {
+       if (nsurl_length(c->url) < 6) {
                /* 6 is the minimum possible length (data:,) */
                msg.type = FETCH_ERROR;
                msg.data.error = "Malformed data: URL";
@@ -160,7 +153,7 @@ static bool fetch_data_process(struct fetch_data_context *c)
        }
        
        /* skip the data: part */
-       params = c->url + SLEN("data:");
+       params = nsurl_access(c->url) + SLEN("data:");
        
        /* find the comma */
        if ( (comma = strchr(params, ',')) == NULL) {
@@ -291,8 +284,8 @@ static void fetch_data_poll(lwc_string *scheme)
                                fetch_data_send_callback(&msg, c);
                        }
                } else {
-                       NSLOG(netsurf, INFO, "Processing of %s failed!",
-                             c->url);
+                       NSLOG(netsurf, INFO, "Processing of %.140s failed!",
+                             nsurl_access(c->url));
 
                        /* Ensure that we're unlocked here. If we aren't, 
                         * then fetch_data_process() is broken.


commitdiff 
http://git.netsurf-browser.org/netsurf.git/commit/?id=47e47244a9dc397293dbf94c9f1e22f715b95ff4
commit 47e47244a9dc397293dbf94c9f1e22f715b95ff4
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>

    data url handling: avoid needless allocation / copy.

diff --git a/content/fetchers/data.c b/content/fetchers/data.c
index c1ea48d..b8710dd 100644
--- a/content/fetchers/data.c
+++ b/content/fetchers/data.c
@@ -216,21 +216,12 @@ static bool fetch_data_process(struct fetch_data_context 
*c)
                        free(unescaped);
                        return false;
                }
+               free(unescaped);
        } else {
-               c->data = malloc(unescaped_len);
-               if (c->data == NULL) {
-                       msg.type = FETCH_ERROR;
-                       msg.data.error =
-                               "Unable to allocate memory for data: URL";
-                       fetch_data_send_callback(&msg, c);
-                       free(unescaped);
-                       return false;
-               }
                c->datalen = unescaped_len;
-               memcpy(c->data, unescaped, unescaped_len);
+               c->data = unescaped;
        }
        
-       free(unescaped);
        
        return true;
 }


commitdiff 
http://git.netsurf-browser.org/netsurf.git/commit/?id=c76b5ef4d548429b5ee3ee87ddd5d917431afd34
commit c76b5ef4d548429b5ee3ee87ddd5d917431afd34
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>

    data URL handler: constify some string pointers.

diff --git a/content/fetchers/data.c b/content/fetchers/data.c
index 5ba021f..c1ea48d 100644
--- a/content/fetchers/data.c
+++ b/content/fetchers/data.c
@@ -138,8 +138,8 @@ static bool fetch_data_process(struct fetch_data_context *c)
 {
        nserror res;
        fetch_msg msg;
-       char *params;
-       char *comma;
+       const char *params;
+       const char *comma;
        char *unescaped;
        size_t unescaped_len;
        


-----------------------------------------------------------------------

Summary of changes:
 content/fetchers/data.c |   40 ++++++++++++----------------------------
 1 file changed, 12 insertions(+), 28 deletions(-)

diff --git a/content/fetchers/data.c b/content/fetchers/data.c
index 5ba021f..7077dd9 100644
--- a/content/fetchers/data.c
+++ b/content/fetchers/data.c
@@ -41,7 +41,7 @@
 
 struct fetch_data_context {
        struct fetch *parent_fetch;
-       char *url;
+       nsurl *url;
        char *mimetype;
        char *data;
        size_t datalen;
@@ -85,14 +85,7 @@ static void *fetch_data_setup(struct fetch *parent_fetch, 
nsurl *url,
                return NULL;
                
        ctx->parent_fetch = parent_fetch;
-
-       /* TODO: keep as nsurl to avoid copy */
-       ctx->url = malloc(nsurl_length(url) + 1);
-       if (ctx->url == NULL) {
-               free(ctx);
-               return NULL;
-       }
-       memcpy(ctx->url, nsurl_access(url), nsurl_length(url) + 1);
+       ctx->url = nsurl_ref(url);
 
        RING_INSERT(ring, ctx);
        
@@ -108,7 +101,7 @@ static void fetch_data_free(void *ctx)
 {
        struct fetch_data_context *c = ctx;
 
-       free(c->url);
+       nsurl_unref(c->url);
        free(c->data);
        free(c->mimetype);
        RING_REMOVE(ring, c);
@@ -138,8 +131,8 @@ static bool fetch_data_process(struct fetch_data_context *c)
 {
        nserror res;
        fetch_msg msg;
-       char *params;
-       char *comma;
+       const char *params;
+       const char *comma;
        char *unescaped;
        size_t unescaped_len;
        
@@ -149,9 +142,9 @@ static bool fetch_data_process(struct fetch_data_context *c)
         * data must still be there.
         */
        
-       NSLOG(netsurf, INFO, "url: %.140s", c->url);
+       NSLOG(netsurf, INFO, "url: %.140s", nsurl_access(c->url));
        
-       if (strlen(c->url) < 6) {
+       if (nsurl_length(c->url) < 6) {
                /* 6 is the minimum possible length (data:,) */
                msg.type = FETCH_ERROR;
                msg.data.error = "Malformed data: URL";
@@ -160,7 +153,7 @@ static bool fetch_data_process(struct fetch_data_context *c)
        }
        
        /* skip the data: part */
-       params = c->url + SLEN("data:");
+       params = nsurl_access(c->url) + SLEN("data:");
        
        /* find the comma */
        if ( (comma = strchr(params, ',')) == NULL) {
@@ -216,21 +209,12 @@ static bool fetch_data_process(struct fetch_data_context 
*c)
                        free(unescaped);
                        return false;
                }
+               free(unescaped);
        } else {
-               c->data = malloc(unescaped_len);
-               if (c->data == NULL) {
-                       msg.type = FETCH_ERROR;
-                       msg.data.error =
-                               "Unable to allocate memory for data: URL";
-                       fetch_data_send_callback(&msg, c);
-                       free(unescaped);
-                       return false;
-               }
                c->datalen = unescaped_len;
-               memcpy(c->data, unescaped, unescaped_len);
+               c->data = unescaped;
        }
        
-       free(unescaped);
        
        return true;
 }
@@ -300,8 +284,8 @@ static void fetch_data_poll(lwc_string *scheme)
                                fetch_data_send_callback(&msg, c);
                        }
                } else {
-                       NSLOG(netsurf, INFO, "Processing of %s failed!",
-                             c->url);
+                       NSLOG(netsurf, INFO, "Processing of %.140s failed!",
+                             nsurl_access(c->url));
 
                        /* Ensure that we're unlocked here. If we aren't, 
                         * then fetch_data_process() is broken.


-- 
NetSurf Browser

_______________________________________________
netsurf-commits mailing list
[email protected]
http://listmaster.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org

Reply via email to