libosmocore 1.10.0.9-9764
Osmocom core library
|
Generic object usage counter Implementation (get, put and deallocate on zero count). More...
#include <errno.h>
#include <inttypes.h>
#include <string.h>
#include <osmocom/core/linuxlist.h>
#include <osmocom/core/utils.h>
#include <osmocom/core/use_count.h>
Functions | |
static bool | count_safe (int32_t *val_p, int32_t add) |
Add two int32_t but make sure to min- and max-clamp at INT32_MIN and INT32_MAX, respectively. More... | |
int32_t | osmo_use_count_total (const struct osmo_use_count *uc) |
Return the sum of all use counts, min- and max-clamped at INT32_MIN and INT32_MAX. More... | |
int32_t | osmo_use_count_by (const struct osmo_use_count *uc, const char *use) |
Return use count by a single use token. More... | |
const char * | osmo_use_count_name_buf (char *buf, size_t buf_len, const struct osmo_use_count *uc) |
Write a comprehensive listing of use counts to a string buffer. More... | |
int | osmo_use_count_to_str_buf (char *buf, size_t buf_len, const struct osmo_use_count *uc) |
Write a comprehensive listing of use counts to a string buffer. More... | |
char * | osmo_use_count_to_str_c (void *ctx, const struct osmo_use_count *uc) |
Write a comprehensive listing of use counts to a talloc allocated string buffer. More... | |
struct osmo_use_count_entry * | osmo_use_count_find (const struct osmo_use_count *uc, const char *use) |
static struct osmo_use_count_entry * | osmo_use_count_repurpose_zero_entry (struct osmo_use_count *uc, const char *use) |
Find a use count entry that currently has zero count, and re-use that for this new use token. More... | |
static struct osmo_use_count_entry * | osmo_use_count_create (struct osmo_use_count *uc, const char *use) |
Allocate a new use count entry, happens implicitly in osmo_use_count_get_put(). More... | |
void | osmo_use_count_free (struct osmo_use_count_entry *use_count_entry) |
Deallocate a use count entry. More... | |
int | _osmo_use_count_get_put (struct osmo_use_count *uc, const char *use, int32_t change, const char *file, int line) |
Implementation for osmo_use_count_get_put(), which can also be directly invoked to pass source file information. More... | |
void | osmo_use_count_make_static_entries (struct osmo_use_count *uc, struct osmo_use_count_entry *buf, size_t buf_n_entries) |
Add N static use token entries to avoid dynamic allocation of use count tokens. More... | |
Generic object usage counter Implementation (get, put and deallocate on zero count).