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

gEDA-cvs: gaf.git: branch: master updated (1.5.0-20080706-86-g0db6ea2)



The branch, master has been updated
       via  0db6ea2341ce7cc8c631df75c4d3c30390590b29 (commit)
      from  0d28977cd5e275a799ec3773f302ddf9b9544fd3 (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
=========

 gschem/src/o_misc.c           |    2 +-
 gschem/src/o_undo.c           |    4 ++--
 libgeda/include/prototype.h   |    3 ++-
 libgeda/src/o_arc_basic.c     |    3 ++-
 libgeda/src/o_box_basic.c     |    4 ++--
 libgeda/src/o_bus_basic.c     |    2 +-
 libgeda/src/o_circle_basic.c  |    4 ++--
 libgeda/src/o_complex_basic.c |   10 ++++------
 libgeda/src/o_line_basic.c    |    9 ++++-----
 libgeda/src/o_net_basic.c     |    2 +-
 libgeda/src/o_picture.c       |   11 +++++------
 libgeda/src/o_pin_basic.c     |    2 +-
 libgeda/src/o_text_basic.c    |    5 ++---
 libgeda/src/s_basic.c         |   30 +++++++++++++++++++++++-------
 libgeda/src/s_page.c          |    2 +-
 15 files changed, 53 insertions(+), 40 deletions(-)


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

commit 0db6ea2341ce7cc8c631df75c4d3c30390590b29
Author: Bernd Jendrissek <bernd.jendrissek@xxxxxxxxx>
Date:   Wed Aug 13 01:55:59 2008 +0100

    Split OBJECT allocation from its initialization.
    
    Split memory allocation for OBJECTs out of s_basic_init_object(). Add a
    new helper function s_basic_new_object() which allocates memory for the
    OBJECT structure, then calls s_basic_init_object().
    
    These changes make it possible to embed an OBJECT structure within
    another struct, or to initialise an OBJECT in static memory.
    
    (Patch modified by Peter Clifton)

:100644 100644 864ee0a... 8bde0b9... M	gschem/src/o_misc.c
:100644 100644 bcd396b... 1e17e5a... M	gschem/src/o_undo.c
:100644 100644 5a40281... b6a7927... M	libgeda/include/prototype.h
:100644 100644 7bfce1a... 2da8ad5... M	libgeda/src/o_arc_basic.c
:100644 100644 8e57f3c... b4ca8d8... M	libgeda/src/o_box_basic.c
:100644 100644 3f3fe93... 467dba9... M	libgeda/src/o_bus_basic.c
:100644 100644 1bfbd04... 43891b4... M	libgeda/src/o_circle_basic.c
:100644 100644 47595c0... 42563c8... M	libgeda/src/o_complex_basic.c
:100644 100644 bcebbf9... db0d750... M	libgeda/src/o_line_basic.c
:100644 100644 a406c9b... 83e098a... M	libgeda/src/o_net_basic.c
:100644 100644 a15ddb0... a1b981b... M	libgeda/src/o_picture.c
:100644 100644 541c0ee... b6bcfd4... M	libgeda/src/o_pin_basic.c
:100644 100644 feb48c4... 9e93835... M	libgeda/src/o_text_basic.c
:100644 100644 8fe7e87... cc36057... M	libgeda/src/s_basic.c
:100644 100644 e16648c... df5e487... M	libgeda/src/s_page.c

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

commit 0db6ea2341ce7cc8c631df75c4d3c30390590b29
Author: Bernd Jendrissek <bernd.jendrissek@xxxxxxxxx>
Date:   Wed Aug 13 01:55:59 2008 +0100

    Split OBJECT allocation from its initialization.
    
    Split memory allocation for OBJECTs out of s_basic_init_object(). Add a
    new helper function s_basic_new_object() which allocates memory for the
    OBJECT structure, then calls s_basic_init_object().
    
    These changes make it possible to embed an OBJECT structure within
    another struct, or to initialise an OBJECT in static memory.
    
    (Patch modified by Peter Clifton)

diff --git a/gschem/src/o_misc.c b/gschem/src/o_misc.c
index 864ee0a..8bde0b9 100644
--- a/gschem/src/o_misc.c
+++ b/gschem/src/o_misc.c
@@ -768,7 +768,7 @@ void o_update_component(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current)
   o_selection_remove( toplevel->page_current->selection_list, o_current);
 
   /* build a temporary list and add a complex to this list */
-  tmp_list = s_basic_init_object(OBJ_HEAD, "update component");
+  tmp_list = s_basic_new_object(OBJ_HEAD, "update component");
   new_complex = o_complex_add (toplevel,
                                tmp_list, NULL,
                                OBJ_COMPLEX,
diff --git a/gschem/src/o_undo.c b/gschem/src/o_undo.c
index bcd396b..1e17e5a 100644
--- a/gschem/src/o_undo.c
+++ b/gschem/src/o_undo.c
@@ -123,7 +123,7 @@ void o_undo_savestate(GSCHEM_TOPLEVEL *w_current, int flag)
       toplevel->page_current->ops_since_last_backup++;
     }
 
-    object_head = s_basic_init_object(OBJ_HEAD, "undo_head");
+    object_head = s_basic_new_object(OBJ_HEAD, "undo_head");
 
     o_list_copy_all(toplevel,
                     toplevel->page_current->object_head->next,
@@ -383,7 +383,7 @@ void o_undo_callback(GSCHEM_TOPLEVEL *w_current, int type)
 
     s_delete_list_fromstart(toplevel, toplevel->page_current->object_head);
 
-    toplevel->page_current->object_head = s_basic_init_object(OBJ_HEAD, "object_head");
+    toplevel->page_current->object_head = s_basic_new_object(OBJ_HEAD, "object_head");
 
     o_list_copy_all(toplevel, u_current->object_head->next,
                     toplevel->page_current->object_head,
diff --git a/libgeda/include/prototype.h b/libgeda/include/prototype.h
index 5a40281..b6a7927 100644
--- a/libgeda/include/prototype.h
+++ b/libgeda/include/prototype.h
@@ -330,7 +330,8 @@ void error_if_called(void);
 void exit_if_null(void *ptr);
 OBJECT *return_tail(OBJECT *head);
 OBJECT *return_head(OBJECT *tail);
-OBJECT *s_basic_init_object(int type, char const *name);
+OBJECT *s_basic_init_object(OBJECT *new_node, int type, char const *name);
+OBJECT *s_basic_new_object(char type, char const *prefix);
 OBJECT *s_basic_link_object(OBJECT *new_node, OBJECT *ptr);
 void print_struct_forw(OBJECT *ptr);
 void print_struct_back(OBJECT *ptr);
diff --git a/libgeda/src/o_arc_basic.c b/libgeda/src/o_arc_basic.c
index 7bfce1a..2da8ad5 100644
--- a/libgeda/src/o_arc_basic.c
+++ b/libgeda/src/o_arc_basic.c
@@ -66,7 +66,8 @@ OBJECT *o_arc_add(TOPLEVEL *toplevel, OBJECT *object_list,
 
   OBJECT *new_node;
 
-  new_node = s_basic_init_object(type, "arc");
+  new_node = s_basic_new_object(type, "arc");
+
   new_node->color = color;
 
   new_node->arc = (ARC *) g_malloc(sizeof(ARC));
diff --git a/libgeda/src/o_box_basic.c b/libgeda/src/o_box_basic.c
index 8e57f3c..b4ca8d8 100644
--- a/libgeda/src/o_box_basic.c
+++ b/libgeda/src/o_box_basic.c
@@ -58,7 +58,7 @@
  *  its lower right corner - <B>x2</B>, <B>y2</B>.
  *  The <B>type</B> parameter must be equal to <B>OBJ_BOX</B>. The <B>color</B>
  *  corresponds to the color the box will be drawn with.
- *  The <B>OBJECT</B> structure is allocated with the #s_basic_init_object()
+ *  The <B>OBJECT</B> structure is allocated with the #s_basic_new_object()
  *  function. The structure describing the box is allocated and initialized
  *  with the parameters given to the function.
  *
@@ -87,7 +87,7 @@ OBJECT *o_box_add(TOPLEVEL *toplevel, OBJECT *object_list,
   BOX *box;
 
   /* create the object */
-  new_node        = s_basic_init_object(type, "box");
+  new_node = s_basic_new_object(type, "box");
   new_node->color = color;
 
   box = (BOX *) g_malloc(sizeof(BOX));
diff --git a/libgeda/src/o_bus_basic.c b/libgeda/src/o_bus_basic.c
index 3f3fe93..467dba9 100644
--- a/libgeda/src/o_bus_basic.c
+++ b/libgeda/src/o_bus_basic.c
@@ -53,7 +53,7 @@ OBJECT *o_bus_add(TOPLEVEL *toplevel, OBJECT *object_list,
   int left, right, top, bottom;
   OBJECT *new_node;
 
-  new_node = s_basic_init_object(type, "bus");
+  new_node = s_basic_new_object(type, "bus");
   new_node->color = color;
 
   new_node->line = (LINE *) g_malloc(sizeof(LINE));
diff --git a/libgeda/src/o_circle_basic.c b/libgeda/src/o_circle_basic.c
index 1bfbd04..43891b4 100644
--- a/libgeda/src/o_circle_basic.c
+++ b/libgeda/src/o_circle_basic.c
@@ -45,7 +45,7 @@ int dist(int x1, int y1, int x2, int y2)
  *  The <B>type</B> parameter must be equal to <B>OBJ_CIRCLE</B>. The <B>color</B>
  *  corresponds to the color the box will be drawn with.
  *
- *  The <B>OBJECT</B> structure is allocated with the #s_basic_init_object()
+ *  The <B>OBJECT</B> structure is allocated with the #s_basic_new_object()
  *  function. The structure describing the circle is allocated and initialized
  *  with the parameters given to the function.
  *
@@ -72,7 +72,7 @@ OBJECT *o_circle_add(TOPLEVEL *toplevel, OBJECT *object_list,
   OBJECT *new_node;	
 
   /* create the object */
-  new_node         = s_basic_init_object(type, "circle");
+  new_node = s_basic_new_object(type, "circle");
   new_node->color  = color;
   
   new_node->circle = (CIRCLE *) g_malloc(sizeof(CIRCLE));
diff --git a/libgeda/src/o_complex_basic.c b/libgeda/src/o_complex_basic.c
index 47595c0..42563c8 100644
--- a/libgeda/src/o_complex_basic.c
+++ b/libgeda/src/o_complex_basic.c
@@ -208,11 +208,11 @@ void world_get_complex_bounds(TOPLEVEL *toplevel, OBJECT *complex,
  *  \par Function Description
  *
  */
-OBJECT *add_head(void)
+OBJECT *add_head()
 {
   OBJECT *new_node=NULL;
 
-  new_node = s_basic_init_object(OBJ_HEAD, "complex_head");
+  new_node = s_basic_new_object(OBJ_HEAD, "complex_head");
 
   /* don't need to do this for head nodes */
   /* ret = (OBJECT *) s_basic_link_object(new_node, NULL);*/
@@ -331,8 +331,7 @@ OBJECT *o_complex_add(TOPLEVEL *toplevel, OBJECT *object_list,
     use_object_list = FALSE;
   }
 
-  new_node = s_basic_init_object(type, "complex");
-  new_node->type = type;
+  new_node = s_basic_new_object(type, "complex");
 
   if (clib != NULL) {
     new_node->complex_basename = g_strdup (s_clib_symbol_get_name (clib));
@@ -616,8 +615,7 @@ OBJECT *o_complex_add_embedded(TOPLEVEL *toplevel, OBJECT *object_list,
   OBJECT *prim_objs=NULL;
   OBJECT *new_node=NULL;
 
-  new_node = s_basic_init_object(type, "complex");
-  new_node->type = type;
+  new_node = s_basic_new_object(type, "complex");
 
   new_node->complex = (COMPLEX *) g_malloc(sizeof(COMPLEX));
   new_node->complex->x = x;
diff --git a/libgeda/src/o_line_basic.c b/libgeda/src/o_line_basic.c
index bcebbf9..db0d750 100644
--- a/libgeda/src/o_line_basic.c
+++ b/libgeda/src/o_line_basic.c
@@ -39,10 +39,9 @@
  *  The <B>color</B> parameter corresponds to the color the box
  *  will be drawn with.
  *
- *  The #OBJECT structure is allocated with the
- *  #s_basic_init_object() function. The structure describing
- *  the line is allocated and initialized with the parameters given
- *  to the function.
+ *  The #OBJECT structure is allocated with the #s_basic_new_object()
+ *  function. The structure describing the line is allocated and
+ *  initialized with the parameters given to the function.
  *
  *  Both the line type and the filling type are set to default
  *  values : solid line type with a width of 0, and no filling.
@@ -69,7 +68,7 @@ OBJECT *o_line_add(TOPLEVEL *toplevel, OBJECT *object_list,
   OBJECT *new_node;
 
   /* create the object */
-  new_node        = s_basic_init_object(type, "line");
+  new_node = s_basic_new_object(type, "line");
   new_node->color = color;
   
   new_node->line  = (LINE *) g_malloc(sizeof(LINE));
diff --git a/libgeda/src/o_net_basic.c b/libgeda/src/o_net_basic.c
index a406c9b..83e098a 100644
--- a/libgeda/src/o_net_basic.c
+++ b/libgeda/src/o_net_basic.c
@@ -65,7 +65,7 @@ OBJECT *o_net_add(TOPLEVEL *toplevel, OBJECT *object_list, char type,
   int left, right, top, bottom;
   OBJECT *new_node;
 
-  new_node = s_basic_init_object(type, "net");
+  new_node = s_basic_new_object(type, "net");
   new_node->color = color;
 
   new_node->line = (LINE *) g_malloc(sizeof(LINE));
diff --git a/libgeda/src/o_picture.c b/libgeda/src/o_picture.c
index a15ddb0..a1b981b 100644
--- a/libgeda/src/o_picture.c
+++ b/libgeda/src/o_picture.c
@@ -304,10 +304,9 @@ char *o_picture_save(OBJECT *object)
  *  and its lower right corner - <B>x2</B>, <B>y2</B>.
  *  The <B>type</B> parameter must be equal to #OBJ_PICTURE. 
  *
- *  The #OBJECT structure is allocated with the
- *  #s_basic_init_object() function. The structure describing the
- *  picture is allocated and initialized with the parameters given to the
- *  function.
+ *  The #OBJECT structure is allocated with the #s_basic_init_object()
+ *  function. The structure describing the picture is allocated and
+ *  initialized with the parameters given to the function.
  *
  *  The object is added to the end of the list described by the
  *  <B>object_list</B> parameter by the #s_basic_link_object().
@@ -344,7 +343,7 @@ OBJECT *o_picture_add(TOPLEVEL *toplevel, OBJECT *list_tail, GdkPixbuf *pixbuf,
   PICTURE *picture;
 
   /* create the object */
-  new_node        = s_basic_init_object(type, "picture");
+  new_node = s_basic_new_object(type, "picture");
 
   picture = (PICTURE *) g_malloc(sizeof(PICTURE));
   new_node->picture = picture;
@@ -682,7 +681,7 @@ OBJECT *o_picture_copy(TOPLEVEL *toplevel, OBJECT *list_tail,
   PICTURE *picture;
 
   /* create the object */
-  new_node = s_basic_init_object(object->type, "picture");
+  new_node = s_basic_new_object(object->type, "picture");
 
   picture = g_malloc(sizeof(PICTURE));
   new_node->picture = picture;
diff --git a/libgeda/src/o_pin_basic.c b/libgeda/src/o_pin_basic.c
index 541c0ee..b6bcfd4 100644
--- a/libgeda/src/o_pin_basic.c
+++ b/libgeda/src/o_pin_basic.c
@@ -51,7 +51,7 @@ OBJECT *o_pin_add(TOPLEVEL *toplevel, OBJECT *object_list,
   int left, right, top, bottom;
   OBJECT *new_node;
 
-  new_node = s_basic_init_object(type, "pin");
+  new_node = s_basic_new_object(type, "pin");
   new_node->color = color;
 
   new_node->line = (LINE *) g_malloc(sizeof(LINE));
diff --git a/libgeda/src/o_text_basic.c b/libgeda/src/o_text_basic.c
index feb48c4..9e93835 100644
--- a/libgeda/src/o_text_basic.c
+++ b/libgeda/src/o_text_basic.c
@@ -72,7 +72,7 @@ OBJECT *o_text_add_head(void)
 {
   OBJECT *new_node=NULL;
 
-  new_node = s_basic_init_object(OBJ_HEAD, "text_head");
+  new_node = s_basic_new_object(OBJ_HEAD, "text_head");
 
   /* don't need to do this for head nodes */
   /* ret = s_basic_link_object(new_node, NULL);*/
@@ -898,8 +898,7 @@ OBJECT *o_text_add(TOPLEVEL *toplevel, OBJECT *object_list,
     return(NULL);
   }
 
-  new_node = s_basic_init_object(type, "text");
-  new_node->type = type;
+  new_node = s_basic_new_object(type, "text");
 
   text = (TEXT *) g_malloc(sizeof(TEXT));
 
diff --git a/libgeda/src/s_basic.c b/libgeda/src/s_basic.c
index 8fe7e87..cc36057 100644
--- a/libgeda/src/s_basic.c
+++ b/libgeda/src/s_basic.c
@@ -104,17 +104,17 @@ OBJECT *return_head(OBJECT *tail)
   return(ret_struct);	
 }
 
-/*! \todo Finish function documentation!!!
- *  \brief
+/*! \brief Initialize an already-allocated object.
  *  \par Function Description
+ *  Initializes the members of the OBJECT structure.
  *
+ *  \param [in] new_node  A pointer to an allocated OBJECT
+ *  \param [in] type      The object type; one of the OBJ_* constants.
+ *  \param [in] name      A prefix for the object's session-unique name.
+ *  \return A pointer to the initialized object.
  */
-OBJECT *s_basic_init_object(int type, char const *name)
+OBJECT *s_basic_init_object(OBJECT *new_node, int type, char const *name)
 {
-  OBJECT *new_node;
-
-  new_node = (OBJECT *) g_malloc(sizeof(OBJECT));	
-
   /* setup sid */
   new_node->sid = global_sid++;
   new_node->type = type;
@@ -188,6 +188,22 @@ OBJECT *s_basic_init_object(int type, char const *name)
   return(new_node);
 }
 
+
+/*! \brief Helper to allocate and initialise an object.
+ *
+ *  \par Function Description
+ *  Allocates memory for an OBJECT and then calls s_basic_init_object() on it.
+ *
+ *  \param [in] type      The sub-type of the object to create; one of the OBJ_* constants.
+ *  \param [in] prefix    The name prefix for the session-unique object name.
+ *  \return A pointer to the fully constructed OBJECT.
+ */
+OBJECT *s_basic_new_object(char type, char const *prefix)
+{
+  return s_basic_init_object(g_malloc(sizeof (OBJECT)), type, prefix);
+}
+
+
 OBJECT *s_basic_link_object( OBJECT *new_node, OBJECT *ptr ) 
 {
   /* should never happen, but could */
diff --git a/libgeda/src/s_page.c b/libgeda/src/s_page.c
index e16648c..df5e487 100644
--- a/libgeda/src/s_page.c
+++ b/libgeda/src/s_page.c
@@ -82,7 +82,7 @@ PAGE *s_page_new (TOPLEVEL *toplevel, const gchar *filename)
   s_tile_init (toplevel, page);
 
   /* First one to setup head */
-  page->object_head = s_basic_init_object(OBJ_HEAD, "object_head");
+  page->object_head = s_basic_new_object(OBJ_HEAD, "object_head");
 
   /* new selection mechanism */
   page->selection_list = o_selection_new();




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