Loading...
Searching...
No Matches
use_count.c File Reference
Use Counter

Generic object usage counter Implementation (get, put and deallocate on zero count). More...

`#include <errno.h>`
`#include <inttypes.h>`
`#include <string.h>`
`#include "config.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.
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.
int32_t | osmo_use_count_by (const struct osmo_use_count *uc, const char *use)
| Return use count by a single use token.
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.
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.
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.
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.
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().
void | osmo_use_count_free (struct osmo_use_count_entry *use_count_entry)
| Deallocate a use count entry.
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.
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.

## Detailed Description

Generic object usage counter Implementation (get, put and deallocate on zero count).