OSSP CVS Repository

ossp - Difference in ossp-pkg/act/act_grid.c versions 1.8 and 1.9
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/act/act_grid.c 1.8 -> 1.9

--- act_grid.c   2002/01/19 13:21:47     1.8
+++ act_grid.c   2002/01/19 13:28:55     1.9
@@ -109,6 +109,7 @@
 struct act_grid_st {
     act_ctx_t                     *g_ctx;              /* context structure */
     ACT_RING_HEAD(act_grid_seg_t)  g_seg;              /* ring of segments */
+    int                            g_seg_num;          /* number of segments */
     size_t                         g_tile_size;        /* size of a tile */
     int                            g_tile_num_first;   /* number of tiles in first segment */
 };
@@ -192,6 +193,7 @@
     grid->g_ctx = act_ctx_dup(ctx, NULL);
     ACT_RING_INIT(&grid->g_seg, act_grid_seg_t, gs_link);
     ACT_RING_INSERT_HEAD(&grid->g_seg, seg, act_grid_seg_t, gs_link);
+    grid->g_seg_num = 1;
     grid->g_tile_size = tile_size;
     grid->g_tile_num_first = tile_num;
 
@@ -267,6 +269,7 @@
         if ((rc = act_grid_seg_create(grid->g_ctx, &seg, grid->g_tile_size, tile_num)) != ACT_OK)
             return rc;
         ACT_RING_INSERT_TAIL(&grid->g_seg, seg, act_grid_seg_t, gs_link);
+        grid->g_seg_num++;
     }
 
     /* allocate tile from segment */
@@ -328,8 +331,10 @@
     seg->gs_tile_free_num++;
 
     /* free segment if it is now empty */
-    if (seg->gs_tile_num == seg->gs_tile_free_num) {
+    if (   grid->g_seg_num > 1
+        && seg->gs_tile_num == seg->gs_tile_free_num) {
         ACT_RING_REMOVE(seg, gs_link);
+        grid->g_seg_num--;
         act_mem_free_ctx(grid->g_ctx, seg);
     }
 

CVSTrac 2.0.1