Revision: 76638
          http://sourceforge.net/p/brlcad/code/76638
Author:   starseeker
Date:     2020-08-01 23:40:26 +0000 (Sat, 01 Aug 2020)
Log Message:
-----------
Start trying to figure out how bu_list is used for the free solids data, and 
what it would take to use a bu_ptbl instead...

Modified Paths:
--------------
    brlcad/branches/bioh/include/ged/defines.h
    brlcad/branches/bioh/src/libged/ged.c

Modified: brlcad/branches/bioh/include/ged/defines.h
===================================================================
--- brlcad/branches/bioh/include/ged/defines.h  2020-08-01 23:18:23 UTC (rev 
76637)
+++ brlcad/branches/bioh/include/ged/defines.h  2020-08-01 23:40:26 UTC (rev 
76638)
@@ -154,10 +154,9 @@
 
 /* FIXME: should be private */
 struct ged_drawable {
-    struct bu_list             *gd_headDisplay;                /**< @brief  
head of display list */
+    struct bu_list             *gd_headDisplay;        /**< @brief  head of 
display list */
     struct bu_list             *gd_headVDraw;          /**< @brief  head of 
vdraw list */
     struct vd_curve            *gd_currVHead;          /**< @brief  current 
vdraw head */
-    struct solid                *gd_freeSolids;         /**< @brief  ptr to 
head of free solid list */
 
     char                       **gd_rt_cmd;    /* DEPRECATED - will be 
removed, do not use */
     int                                gd_rt_cmd_len;  /* DEPRECATED - will be 
removed, do not use */
@@ -200,6 +199,7 @@
     struct bu_vls              *ged_log;
 
     struct solid                *freesolid;  /* For now this is a struct 
solid, but longer term that may not always be true */
+    struct bu_ptbl              free_solids; /**< @brief  solid structures 
available for reuse */
 
     /* @todo: add support for returning an array of objects, not just a
      * simple string.

Modified: brlcad/branches/bioh/src/libged/ged.c
===================================================================
--- brlcad/branches/bioh/src/libged/ged.c       2020-08-01 23:18:23 UTC (rev 
76637)
+++ brlcad/branches/bioh/src/libged/ged.c       2020-08-01 23:40:26 UTC (rev 
76638)
@@ -175,6 +175,20 @@
     bu_ptbl_free(&gedp->ged_views);
 
     if (gedp->ged_gdp != GED_DRAWABLE_NULL) {
+
+       for (size_t i = 0; i < BU_PTBL_LEN(&gedp->free_solids); i++) {
+           // TODO - FREE_SOLID macro is stashing on the freesolid list, not
+           // BU_PUT-ing the solid objects themselves - is that what we expect
+           // when doing ged_free?  I.e., is ownership of the free solid list
+           // with the struct ged or with the application as a whole?  We're
+           // BU_PUT-ing gedp->freesolid - above why just that one?
+#if 0
+           struct solid *sp = (struct solid *)BU_PTBL_GET(&gedp->free_solids, 
i);
+           RT_FREE_VLIST(&(sp->s_vlist));
+#endif
+       }
+       bu_ptbl_free(&gedp->free_solids);
+
        if (gedp->ged_gdp->gd_headDisplay)
            BU_PUT(gedp->ged_gdp->gd_headDisplay, struct bu_vls);
        if (gedp->ged_gdp->gd_headVDraw)
@@ -198,6 +212,7 @@
        BU_PUT(gedp->ged_result_str, struct bu_vls);
     }
 
+    // TODO - replace freesolid with free_solids ptbl
     {
        struct solid *nsp;
        sp = BU_LIST_NEXT(solid, &gedp->freesolid->l);
@@ -221,8 +236,6 @@
 void
 ged_init(struct ged *gedp)
 {
-    struct solid *freesolid;
-
     if (gedp == GED_NULL)
        return;
 
@@ -257,11 +270,17 @@
     gedp->ged_selections = bu_hash_create(32);
 
     /* init the solid list */
+    struct solid *freesolid;
     BU_GET(freesolid, struct solid);
     BU_LIST_INIT(&freesolid->l);
     gedp->freesolid = freesolid;
-    gedp->ged_gdp->gd_freeSolids = freesolid;
 
+    /* TODO: If we're init-ing the list here, does that mean the gedp has
+     * ownership of all solid objects created and stored here, and should we
+     * then free them when ged_free is called? (don't appear to be currently,
+     * just calling FREE_SOLID which doesn't de-allocate... */
+    BU_PTBL_INIT(&gedp->free_solids);
+
     /* Initialize callbacks */
     BU_GET(gedp->ged_cbs, struct ged_callback_state);
     gedp->ged_refresh_handler = NULL;

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to