glib r7861 - in trunk: . glib
- From: hasselmm svn gnome org
- To: svn-commits-list gnome org
- Subject: glib r7861 - in trunk: . glib
- Date: Fri, 13 Feb 2009 14:20:17 +0000 (UTC)
Author: hasselmm
Date: Fri Feb 13 14:20:17 2009
New Revision: 7861
URL: http://svn.gnome.org/viewvc/glib?rev=7861&view=rev
Log:
Add note about g_utf8_offset_to_pointer() not checking string
boundaries.
* glib/gutf8.c (g_utf8_offset_to_pointer()): See summary.
Modified:
trunk/ChangeLog
trunk/glib/gutf8.c
Modified: trunk/glib/gutf8.c
==============================================================================
--- trunk/glib/gutf8.c (original)
+++ trunk/glib/gutf8.c Fri Feb 13 14:20:17 2009
@@ -279,20 +279,29 @@
* g_utf8_offset_to_pointer:
* @str: a UTF-8 encoded string
* @offset: a character offset within @str
- *
+ *
* Converts from an integer character offset to a pointer to a position
* within the string.
- *
+ *
* Since 2.10, this function allows to pass a negative @offset to
* step backwards. It is usually worth stepping backwards from the end
- * instead of forwards if @offset is in the last fourth of the string,
+ * instead of forwards if @offset is in the last fourth of the string,
* since moving forward is about 3 times faster than moving backward.
- *
+ *
+ * <note><para>
+ * This function doesn't abort when reaching the end of @str. Therefore
+ * you should be sure that @offset is within string boundaries before
+ * calling that function. Call g_utf8_strlen() when unsure.
+ *
+ * This limitation exists as this function is called frequently during
+ * text rendering and therefore has to be as fast as possible.
+ * </para></note>
+ *
* Return value: the resulting pointer
**/
gchar *
g_utf8_offset_to_pointer (const gchar *str,
- glong offset)
+ glong offset)
{
const gchar *s = str;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]