glib r7807 - in trunk: . docs/reference docs/reference/glib docs/reference/glib/tmpl glib
- From: matthiasc svn gnome org
- To: svn-commits-list gnome org
- Subject: glib r7807 - in trunk: . docs/reference docs/reference/glib docs/reference/glib/tmpl glib
- Date: Tue, 13 Jan 2009 19:59:32 +0000 (UTC)
Author: matthiasc
Date: Tue Jan 13 19:59:32 2009
New Revision: 7807
URL: http://svn.gnome.org/viewvc/glib?rev=7807&view=rev
Log:
2009-01-13 Matthias Clasen <mclasen redhat com>
Bug 564728 Add function to decode base64 encoded data in place
* glib/glib.symbols:
* glib/gbase64.[hc] (g_base64_decode_inplace): New convenience
API to decode in place, overwriting the input string. Patch by
Sebastian DrÃge.
Modified:
trunk/ChangeLog
trunk/docs/reference/ChangeLog
trunk/docs/reference/glib/glib-sections.txt
trunk/docs/reference/glib/tmpl/base64.sgml
trunk/glib/gbase64.c
trunk/glib/gbase64.h
trunk/glib/glib.symbols
Modified: trunk/docs/reference/glib/glib-sections.txt
==============================================================================
--- trunk/docs/reference/glib/glib-sections.txt (original)
+++ trunk/docs/reference/glib/glib-sections.txt Tue Jan 13 19:59:32 2009
@@ -2527,6 +2527,7 @@
g_base64_encode
g_base64_decode_step
g_base64_decode
+g_base64_decode_inplace
</SECTION>
<SECTION>
Modified: trunk/docs/reference/glib/tmpl/base64.sgml
==============================================================================
--- trunk/docs/reference/glib/tmpl/base64.sgml (original)
+++ trunk/docs/reference/glib/tmpl/base64.sgml Tue Jan 13 19:59:32 2009
@@ -18,7 +18,8 @@
GLib supports incremental encoding using g_base64_encode_step() and
g_base64_encode_close(). Incremental decoding can be done with
g_base64_decode_step(). To encode or decode data in one go, use
-g_base64_encode() or g_base64_decode().
+g_base64_encode() or g_base64_decode(). To avoid memory allocation when
+decoding, you can use g_base64_decode_inplace().
</para>
<para>
Modified: trunk/glib/gbase64.c
==============================================================================
--- trunk/glib/gbase64.c (original)
+++ trunk/glib/gbase64.c Tue Jan 13 19:59:32 2009
@@ -374,6 +374,39 @@
return ret;
}
+
+/**
+ * g_base64_decode_inplace:
+ * @text: zero-terminated string with base64 text to decode
+ * @out_len: The length of the decoded data is written here
+ *
+ * Decode a sequence of Base-64 encoded text into binary data
+ * by overwriting the input data.
+ *
+ * Return value: The binary data that @text responds. This pointer
+ * is the same as the input @text.
+ *
+ * Since: 2.20
+ */
+guchar *
+g_base64_decode_inplace (gchar *text,
+ gsize *out_len)
+{
+ gint input_length, state = 0;
+ guint save = 0;
+
+ g_return_val_if_fail (text != NULL, NULL);
+ g_return_val_if_fail (out_len != NULL, NULL);
+
+ input_length = strlen (text);
+
+ g_return_val_if_fail (input_length > 1, NULL);
+
+ *out_len = g_base64_decode_step (text, input_length, (guchar *) text, &state, &save);
+
+ return text;
+}
+
#define __G_BASE64_C__
#include "galiasdef.c"
Modified: trunk/glib/gbase64.h
==============================================================================
--- trunk/glib/gbase64.h (original)
+++ trunk/glib/gbase64.h Tue Jan 13 19:59:32 2009
@@ -48,6 +48,9 @@
guint *save);
guchar *g_base64_decode (const gchar *text,
gsize *out_len) G_GNUC_MALLOC;
+guchar *g_base64_decode_inplace (gchar *text,
+ gsize *out_len);
+
G_END_DECLS
Modified: trunk/glib/glib.symbols
==============================================================================
--- trunk/glib/glib.symbols (original)
+++ trunk/glib/glib.symbols Tue Jan 13 19:59:32 2009
@@ -111,6 +111,7 @@
g_base64_encode G_GNUC_MALLOC
g_base64_decode_step
g_base64_decode G_GNUC_MALLOC
+g_base64_decode_inplace
#endif
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]