OSSP CVS Repository

ossp - Check-in [1590]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 1590
Date: 2002-Jan-19 14:18:01 (local)
2002-Jan-19 13:18:01 (UTC)
User:rse
Branch:
Comment: Add act_grid_stat() function for querying statistics about the grid.
Tickets:
Inspections:
Files:
ossp-pkg/act/act_grid.c      1.6 -> 1.7     48 inserted, 0 deleted
ossp-pkg/act/act_grid.h      1.4 -> 1.5     2 inserted, 1 deleted

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;
+}
+


ossp-pkg/act/act_grid.h 1.4 -> 1.5

--- act_grid.h   2002/01/18 17:31:39     1.4
+++ act_grid.h   2002/01/19 13:18:01     1.5
@@ -34,8 +34,9 @@
 
 extern act_rc_t act_grid_create (act_grid_t **grid, act_ctx_t *ctx, size_t tile_size, int tile_num);
 extern act_rc_t act_grid_alloc  (act_grid_t  *grid, void **tile);
-extern act_rc_t act_grid_free   (act_grid_t  *grid, void  *tile);
 extern act_rc_t act_grid_inside (act_grid_t  *grid, void  *tile);
+extern act_rc_t act_grid_free   (act_grid_t  *grid, void  *tile);
+extern act_rc_t act_grid_stat   (act_grid_t  *grid, int *chunks, int *bytes_mgmt, int *bytes_used, int *bytes_free, int *tiles_used, int *tiles_free);
 extern act_rc_t act_grid_destroy(act_grid_t  *grid);
 
 #endif /* __ACT_GRID_H__ */

CVSTrac 2.0.1