libosmocore 1.13.1.1-afb4 Osmocom core library

Data Structures | Macros | Typedefs | Functions
use_count.h File Reference
Use Counter

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

`#include <stdint.h>`
`#include <stdlib.h>`
`#include <osmocom/core/linuxlist.h>`

Go to the source code of this file.

## Data Structures
struct | osmo_use_count
| Use counter state for one used object, managing N distinct named counters. More...
struct | osmo_use_count_entry
| One named counter in the list managed by osmo_use_count. More...

## Macros
#define | osmo_use_count_get_put(USE_LIST, USE, CHANGE) _osmo_use_count_get_put(USE_LIST, USE, CHANGE, __FILE__, __LINE__)
| Change the use count for a given use token. More...

## Typedefs
typedef int(* | osmo_use_count_cb_t) (struct osmo_use_count_entry *use_count_entry, int32_t old_use_count, const char *file, int line)
| Invoked when a use count changes. More...

## Functions
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...
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...
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...
struct osmo_use_count_entry * | osmo_use_count_find (const struct osmo_use_count *uc, const char *use)
void | osmo_use_count_free (struct osmo_use_count_entry *use_count_entry)
| Deallocate a use count entry. 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...

## Detailed Description

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