[svn] pinentry - r205 - in trunk: . gtk+-2

svn author marcus cvs at cvs.gnupg.org
Fri Jun 19 02:09:53 CEST 2009


Author: marcus
Date: 2009-06-19 02:09:52 +0200 (Fri, 19 Jun 2009)
New Revision: 205

Modified:
   trunk/ChangeLog
   trunk/gtk+-2/gtksecentry.c
   trunk/gtk+-2/gtksecentry.h
   trunk/gtk+-2/pinentry-gtk-2.c
Log:
2009-06-19  Marcus Brinkmann  <marcus at g10code.de>

	Suggested by Simon McVittie:
	* gtk+-2/gtksecentry.c (g_malloc, g_realloc, g_free): Renamed to
	secentry_malloc, secentry_realloc.
	(g_malloc0): Removed.
	(GMALLOC_SIZE): Move to ...
	* gtk+-2/gtksecentry.h (GMALLOC_SIZE): ... here.
	(secentry_malloc, secentry_realloc, secentry_free): New prototypes.
	* gtk+-2/pinentry-gtk-2.c (main): Set memory allocation vtable.


Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2009-05-04 14:06:30 UTC (rev 204)
+++ trunk/ChangeLog	2009-06-19 00:09:52 UTC (rev 205)
@@ -1,3 +1,14 @@
+2009-06-19  Marcus Brinkmann  <marcus at g10code.de>
+
+	Suggested by Simon McVittie:
+	* gtk+-2/gtksecentry.c (g_malloc, g_realloc, g_free): Renamed to
+	secentry_malloc, secentry_realloc.
+	(g_malloc0): Removed.
+	(GMALLOC_SIZE): Move to ...
+	* gtk+-2/gtksecentry.h (GMALLOC_SIZE): ... here.
+	(secentry_malloc, secentry_realloc, secentry_free): New prototypes.
+	* gtk+-2/pinentry-gtk-2.c (main): Set memory allocation vtable.
+
 2009-05-04  Till Adam <till at kdab.net>
 
 	* qt4/main.cpp (qt_cmd_handler): Use WId instead of HWND.

Modified: trunk/gtk+-2/gtksecentry.c
===================================================================
--- trunk/gtk+-2/gtksecentry.c	2009-05-04 14:06:30 UTC (rev 204)
+++ trunk/gtk+-2/gtksecentry.c	2009-06-19 00:09:52 UTC (rev 205)
@@ -269,14 +269,8 @@
 				} while(0)
 
 
-#if GLIB_CHECK_VERSION (2,15,5)
-#define GMALLOC_SIZE gsize
-#else
-#define GMALLOC_SIZE gulong
-#endif
-
 gpointer
-g_malloc (GMALLOC_SIZE size)
+secentry_malloc (GMALLOC_SIZE size)
 {
     gpointer p;
 
@@ -293,28 +287,9 @@
     return p;
 }
 
-gpointer
-g_malloc0 (GMALLOC_SIZE size)
-{
-    gpointer p;
 
-    if (size == 0)
-	return NULL;
-
-    if (g_use_secure_mem) {
-	p = (gpointer) secmem_malloc(size);
-	if (p)
-	    memset(p, 0, size);
-    } else
-	p = (gpointer) calloc(size, 1);
-    if (!p)
-	g_error("could not allocate %ld bytes", size);
-
-    return p;
-}
-
 gpointer
-g_realloc (gpointer mem, GMALLOC_SIZE size)
+secentry_realloc (gpointer mem, GMALLOC_SIZE size)
 {
     gpointer p;
 
@@ -344,7 +319,7 @@
 }
 
 void
-g_free(gpointer mem)
+secentry_free(gpointer mem)
 {
     if (mem) {
 	if (m_is_secure(mem))

Modified: trunk/gtk+-2/gtksecentry.h
===================================================================
--- trunk/gtk+-2/gtksecentry.h	2009-05-04 14:06:30 UTC (rev 204)
+++ trunk/gtk+-2/gtksecentry.h	2009-06-19 00:09:52 UTC (rev 205)
@@ -173,6 +173,16 @@
 gtk_secure_entry_get_layout_offsets(GtkSecureEntry * entry,
 				    gint * x, gint * y);
 
+#if GLIB_CHECK_VERSION (2,15,5)
+#define GMALLOC_SIZE gsize
+#else
+#define GMALLOC_SIZE gulong
+#endif
+
+gpointer secentry_malloc (GMALLOC_SIZE size);
+gpointer secentry_realloc (gpointer mem, GMALLOC_SIZE size);
+void secentry_free (gpointer mem);
+
 #ifdef __cplusplus
 }
 #endif				/* __cplusplus */

Modified: trunk/gtk+-2/pinentry-gtk-2.c
===================================================================
--- trunk/gtk+-2/pinentry-gtk-2.c	2009-05-04 14:06:30 UTC (rev 204)
+++ trunk/gtk+-2/pinentry-gtk-2.c	2009-06-19 00:09:52 UTC (rev 205)
@@ -531,6 +531,18 @@
 int
 main (int argc, char *argv[])
 {
+  static GMemVTable secure_mem =
+    {
+      secentry_malloc,
+      secentry_realloc,
+      secentry_free,
+      NULL,
+      NULL,
+      NULL
+    };
+
+  g_mem_set_vtable (&secure_mem);
+
   pinentry_init (PGMNAME);
     
 #ifdef FALLBACK_CURSES




More information about the Gnupg-commits mailing list