changeset 31857:c2fa3a76a0be

Get rid fo purple_strlcpy and purple_strlcat. These are convenience functions that call g_strlcpy and g_strlcat. They're only mildly convenient, though. And only used in one place. The reason I don't like them is that I think it's easy to use them incorrectly. It's easy to use the functions and not realize that they use sizeof() to determine the size of the destination buffer. I think it's too easy to accidentally use these functions with a string on the heap (which wouldn't work correctly).
author Mark Doliner <mark@kingant.net>
date Sun, 21 Aug 2011 01:04:31 +0000
parents 9ed25c58e7ce
children 489b20ff1c72
files ChangeLog.API libpurple/internal.h libpurple/util.c
diffstat 3 files changed, 3 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog.API	Sun Aug 21 00:54:23 2011 +0000
+++ b/ChangeLog.API	Sun Aug 21 01:04:31 2011 +0000
@@ -10,6 +10,8 @@
 
 		Removed:
 		* purple_core_migrate
+		* purple_strlcat
+		* purple_strlcpy
 
 version 2.10.0:
 	libpurple:
--- a/libpurple/internal.h	Sun Aug 21 00:54:23 2011 +0000
+++ b/libpurple/internal.h	Sun Aug 21 01:04:31 2011 +0000
@@ -151,12 +151,6 @@
 
 #include <glib-object.h>
 
-/* Safer ways to work with static buffers. When using non-static
- * buffers, either use g_strdup_* functions (preferred) or use
- * g_strlcpy/g_strlcpy directly. */
-#define purple_strlcpy(dest, src) g_strlcpy(dest, src, sizeof(dest))
-#define purple_strlcat(dest, src) g_strlcat(dest, src, sizeof(dest))
-
 #define PURPLE_WEBSITE "http://pidgin.im/"
 #define PURPLE_DEVEL_WEBSITE "http://developer.pidgin.im/"
 
--- a/libpurple/util.c	Sun Aug 21 00:54:23 2011 +0000
+++ b/libpurple/util.c	Sun Aug 21 01:04:31 2011 +0000
@@ -612,7 +612,7 @@
 	}
 	else
 	{
-		purple_strlcpy(buf, utf8);
+		g_strlcpy(buf, utf8, sizeof(buf));
 		g_free(utf8);
 	}