}
/* is list empty? */
-static inline bool list_empty(List *list)
+static inline bool list_empty(const List *list)
{
return list->next == list;
}
}
/* remove first from list and return */
-static inline List *list_first(List *list)
+static inline List *list_first(const List *list)
{
if (list_empty(list))
return NULL;
(item) != (list); \
(item) = (tmp), (tmp) = (tmp)->next)
-static inline bool item_in_list(List *item, List *list)
+static inline bool item_in_list(const List *item, const List *list)
{
List *tmp;
list_for_each(tmp, list)
#endif
}
-static inline int statlist_count(StatList *list)
+static inline int statlist_count(const StatList *list)
{
Assert(list->cur_count > 0 || list_empty(&list->head));
return list->cur_count;
src->cur_count = 0;
}
-static inline List *statlist_first(StatList *list)
+static inline List *statlist_first(const StatList *list)
{
return list_first(&list->head);
}
-static inline bool statlist_empty(StatList *list)
+static inline bool statlist_empty(const StatList *list)
{
return list_empty(&list->head);
}
void * obj_alloc(ObjectCache *cache) _MALLOC _MUSTCHECK;
void obj_free(ObjectCache *cache, void *obj);
-int objcache_total_count(ObjectCache *cache);
-int objcache_free_count(ObjectCache *cache);
-int objcache_active_count(ObjectCache *cache);
+int objcache_total_count(const ObjectCache *cache);
+int objcache_free_count(const ObjectCache *cache);
+int objcache_active_count(const ObjectCache *cache);
typedef void (*slab_stat_fn)(void *arg, const char *slab_name,
unsigned size, unsigned free,
}
/* total number of objects allocated from cache */
-int objcache_total_count(ObjectCache *cache)
+int objcache_total_count(const ObjectCache *cache)
{
return cache->total_count;
}
/* free objects in cache */
-int objcache_free_count(ObjectCache *cache)
+int objcache_free_count(const ObjectCache *cache)
{
return statlist_count(&cache->freelist);
}
/* number of objects in use */
-int objcache_active_count(ObjectCache *cache)
+int objcache_active_count(const ObjectCache *cache)
{
return objcache_total_count(cache) - objcache_free_count(cache);
}