OSSP CVS Repository

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

ossp-pkg/act/act_grid.c 1.6 -> 1.7

--- act_grid.c   2002/01/19 13:16:32     1.6
+++ act_grid.c   2002/01/19 13:18:01     1.7
@@ -362,3 +362,51 @@
     return act_grid_seg_find(grid, NULL, tile);
 }
 
+/* determine grid statistics */
+act_rc_t 
+act_grid_stat(
+    act_grid_t *grid, 
+    int *pchunks, 
+    int *pbytes_mgmt, int *pbytes_used, int *pbytes_free, 
+    int *ptiles_used, int *ptiles_free)
+{
+    act_grid_seg_t *seg;
+    int chunks = 0;
+    int bytes_mgmt = 0;
+    int bytes_used = 0;
+    int bytes_free = 0;
+    int tiles_used = 0;
+    int tiles_free = 0;
+
+    /* consistency checks */
+    act_argcheck(grid != NULL);
+
+    /* determine statistic information */
+    bytes_mgmt += sizeof(act_grid_t);
+    chunks += 1;
+    ACT_RING_FOREACH(seg, &grid->g_seg, act_grid_seg_t, gs_link) {
+        chunks++;
+        bytes_mgmt += sizeof(act_grid_seg_t);
+        bytes_used += ((seg->gs_tile_num - seg->gs_tile_free_num) * grid->g_tile_size);
+        bytes_free += (seg->gs_tile_free_num * grid->g_tile_size);
+        tiles_used += (seg->gs_tile_num - seg->gs_tile_free_num);
+        tiles_free += seg->gs_tile_free_num;
+    }
+
+    /* pass statistic information to caller */
+    if (pchunks != NULL)
+        *pchunks = chunks;
+    if (pbytes_mgmt != NULL)
+        *pbytes_mgmt = bytes_mgmt;
+    if (pbytes_used != NULL)
+        *pbytes_used = bytes_used;
+    if (pbytes_free != NULL)
+        *pbytes_free = bytes_free;
+    if (ptiles_used != NULL)
+        *ptiles_used = tiles_used;
+    if (ptiles_free != NULL)
+        *ptiles_free = tiles_free;
+
+    return ACT_OK;
+}
+

CVSTrac 2.0.1