Hi, Here is a patch that adds two new functions to rmm for obtaining the first and next allocated memory blocks. This is useful in searching or maintaining the entire rmm and skips the need for allocating the array of allocated blocks.
Well, the code is self explanatory I hope. Any objections for commit that to the trunk? Regards -- ^(TM)
Index: include/apr_rmm.h =================================================================== --- include/apr_rmm.h (revision 713315) +++ include/apr_rmm.h (working copy) @@ -129,6 +129,19 @@ */ APU_DECLARE(apr_size_t) apr_rmm_overhead_get(int n); +/** + * Retrieve the first used memory segment of relocatable memory. + * @param rmm The relocatable memory block + */ +APU_DECLARE(apr_rmm_off_t) apr_rmm_first_get(apr_rmm_t *rmm); + +/** + * Retrieve the first used memory segment of relocatable memory. + * @param rmm The relocatable memory block + * @param prev The previous memory block + */ +APU_DECLARE(apr_rmm_off_t) apr_rmm_next_get(apr_rmm_t *rmm, apr_rmm_off_t prev); + #ifdef __cplusplus } #endif Index: misc/apr_rmm.c =================================================================== --- misc/apr_rmm.c (revision 713315) +++ misc/apr_rmm.c (working copy) @@ -444,3 +444,14 @@ * structure. */ return RMM_HDR_BLOCK_SIZE + n * (RMM_BLOCK_SIZE + APR_ALIGN_DEFAULT(1)); } + +APU_DECLARE(apr_rmm_off_t) apr_rmm_first_get(apr_rmm_t *rmm) +{ + return rmm->base->firstused; +} + +APU_DECLARE(apr_rmm_off_t) apr_rmm_next_get(apr_rmm_t *rmm, apr_rmm_off_t prev) +{ + rmm_block_t *blk = (rmm_block_t *)((char*)rmm->base + prev); + return blk->next; +}