[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

gEDA-cvs: pcb.git: branch: master updated (7f9432d189a8824a418da803a43cf02d1d0916b8)



The branch, master has been updated
       via  7f9432d189a8824a418da803a43cf02d1d0916b8 (commit)
       via  d24a35e1771ad753fa7430479ab01b847222b67e (commit)
      from  300031d67ff186c4a4e74fb046d97a74c7d40732 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


=========
 Summary
=========

 src/free_atexit.c            |   11 ++++++++++-
 src/free_atexit.h            |    3 +++
 src/hid/gtk/gui-top-window.c |    5 +++--
 3 files changed, 16 insertions(+), 3 deletions(-)


=================
 Commit Messages
=================

commit 7f9432d189a8824a418da803a43cf02d1d0916b8
Author: Tibor Palinkas <geda@xxxxxxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>

    hid/gtk: Use leaky_* functions for deliberate leaks in ghid_ui_info_append
    
    Allocate cached temporary memory with the leak_* memory allocation wrapers
    which allow these to be freed at exit.

:100644 100644 90977e2... 817c453... M	src/hid/gtk/gui-top-window.c

commit d24a35e1771ad753fa7430479ab01b847222b67e
Author: Tibor Palinkas <geda@xxxxxxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>

    free_atexit.c: Add leaky_calloc() function for deliberately leaked calloc's
    
    Stores a pointer to the calloc'd memory to be free'd at exit of the
    program. Returned memory must not be free'd manually.

:100644 100644 dc11f12... 501775c... M	src/free_atexit.c
:100644 100644 3b142b6... 558b597... M	src/free_atexit.h

=========
 Changes
=========

commit 7f9432d189a8824a418da803a43cf02d1d0916b8
Author: Tibor Palinkas <geda@xxxxxxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>

    hid/gtk: Use leaky_* functions for deliberate leaks in ghid_ui_info_append
    
    Allocate cached temporary memory with the leak_* memory allocation wrapers
    which allow these to be freed at exit.

diff --git a/src/hid/gtk/gui-top-window.c b/src/hid/gtk/gui-top-window.c
index 90977e2..817c453 100644
--- a/src/hid/gtk/gui-top-window.c
+++ b/src/hid/gtk/gui-top-window.c
@@ -119,6 +119,7 @@ a zoom in/out.
 #include "set.h"
 #include "undo.h"
 #include "vendor.h"
+#include "free_atexit.h"
 
 #include "gui-icons-mode-buttons.data"
 #include "gui-icons-misc.data"
@@ -3679,7 +3680,7 @@ ghid_ui_info_append (const gchar * new)
   if (new_ui_info_sz == 0) 
     {
       new_ui_info_sz = 1024;
-      new_ui_info = (gchar *) calloc ( new_ui_info_sz, sizeof (gchar));
+      new_ui_info = leaky_calloc (new_ui_info_sz, sizeof (gchar));
     }
 
   while (strlen (new_ui_info) + strlen (new) + 1 > new_ui_info_sz)
@@ -3688,7 +3689,7 @@ ghid_ui_info_append (const gchar * new)
       gchar * np;
 
       n = new_ui_info_sz + 1024;
-      if ( (np = realloc (new_ui_info, n)) == NULL)
+      if ((np = leaky_realloc (new_ui_info, n)) == NULL)
 	{
 	  fprintf (stderr, "ghid_ui_info_append():  realloc of size %ld failed\n",
 		   (long int) n);

commit d24a35e1771ad753fa7430479ab01b847222b67e
Author: Tibor Palinkas <geda@xxxxxxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>

    free_atexit.c: Add leaky_calloc() function for deliberately leaked calloc's
    
    Stores a pointer to the calloc'd memory to be free'd at exit of the
    program. Returned memory must not be free'd manually.

diff --git a/src/free_atexit.c b/src/free_atexit.c
index dc11f12..501775c 100644
--- a/src/free_atexit.c
+++ b/src/free_atexit.c
@@ -22,8 +22,8 @@
  *
  */
 
-
 #include <stdlib.h>
+#include <string.h>
 
 /* we need one ID per context - short int with 64k IDs should be enough */
 typedef unsigned int leaky_idx_t;
@@ -56,6 +56,15 @@ void *leaky_malloc (size_t size)
   return new_memory + sizeof(leaky_admin_t);
 }
 
+void *leaky_calloc (size_t nmemb, size_t size)
+{
+  size_t size_ = size * nmemb;
+  void *new_memory = leaky_malloc (size_);
+
+  memset (new_memory, 0, size_);
+  return new_memory;
+}
+
 void *leaky_realloc (void* old_memory, size_t size)
 {
   void *new_memory;
diff --git a/src/free_atexit.h b/src/free_atexit.h
index 3b142b6..558b597 100644
--- a/src/free_atexit.h
+++ b/src/free_atexit.h
@@ -23,6 +23,9 @@ void leaky_uninit (void);
 /* allocate memory, remember the pointer and free it after exit from the application */
 void *leaky_malloc (size_t size);
 
+/* same as leaky_malloc but this one wraps calloc() */
+void *leaky_calloc (size_t nmemb, size_t size);
+
 /* reallocate memory, remember the new pointer and free it after exit from the application */
 void *leaky_realloc (void* old_memory, size_t size);
 




_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs