[librsvg] rsvg_handle_load_extern(): Use a stream; don't slurp the whole file first
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg] rsvg_handle_load_extern(): Use a stream; don't slurp the whole file first
- Date: Tue, 27 Nov 2018 00:24:12 +0000 (UTC)
commit d4cd43d23ef50866483341268f65499985900e7a
Author: Federico Mena Quintero <federico gnome org>
Date: Mon Nov 26 13:48:30 2018 -0600
rsvg_handle_load_extern(): Use a stream; don't slurp the whole file first
librsvg/rsvg-handle.c | 26 +++++++++++++++-----------
1 file changed, 15 insertions(+), 11 deletions(-)
---
diff --git a/librsvg/rsvg-handle.c b/librsvg/rsvg-handle.c
index 1241e7e3..9bbca717 100644
--- a/librsvg/rsvg-handle.c
+++ b/librsvg/rsvg-handle.c
@@ -1014,24 +1014,28 @@ RsvgHandle *
rsvg_handle_load_extern (RsvgHandle *handle, const char *uri)
{
RsvgHandle *res = NULL;
- char *data;
- gsize data_len;
+ GInputStream *stream;
+
+ stream = _rsvg_handle_acquire_stream (handle, uri, NULL);
- data = _rsvg_handle_acquire_data (handle, uri, NULL, &data_len, NULL);
+ if (stream) {
+ GFile *file = g_file_new_for_uri (uri);
- if (data) {
- res = rsvg_handle_new ();
- rsvg_handle_set_base_uri (res, uri);
+ res = rsvg_handle_new_from_stream_sync (stream,
+ file,
+ handle->priv->flags,
+ NULL,
+ NULL);
+
+ g_object_unref (file);
- if (rsvg_handle_write (res, (guchar *) data, data_len, NULL)
- && rsvg_handle_close (res, NULL)) {
+ if (res) {
rsvg_tree_cascade (res->priv->tree);
} else {
- g_object_unref (res);
- res = NULL;
+ /* FIXME: rsvg_log!("could not load external resource"); */
}
- g_free (data);
+ g_object_unref (stream);
}
return res;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]