Loading...
Searching...
No Matches
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.

## 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.

## 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.
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.
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.
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.
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 API (get, put and deallocate on zero count).