ascii-chat
Binary v0.15.83-53-gb711d8720
Library lib/v0.3.2-701-gb711d8720
Video chat in your terminal
Loading...
Searching...
No Matches
named.c File Reference

Named object registry for debugging. More...

Go to the source code of this file.

Data Structures

struct  named_entry
 Registry entry for uthash. More...
struct  named_registry_t
 Global registry with uthash and rwlock. More...
struct  named_iter_entry_t

Macros

#define DEBUG_NAMED_FINAL_BASE_NAME_BUFFER_SIZE   256
#define uthash_malloc(sz)
#define uthash_free(ptr, sz)
#define MAX_NAME_LEN   256
#define DESCRIBE_BUFFER_SIZE   768

Typedefs

typedef struct named_entry named_entry_t
 Registry entry for uthash.

Functions

bool named_metadata_copy (uintptr_t key, named_metadata_t *output)
asciichat_error_t named_init (void)
 Initialize the named object registry.
void named_destroy (void)
 Destroy the named object registry.
const char * named_register (uintptr_t key, const char *base_name, const char *type, const char *format_spec, const char *file, int line, const char *func, uintptr_t parent_key)
 Register a resource with an auto-suffixed name, type, and location info.
const char * named_register_fmt (uintptr_t key, const char *type, const char *format_spec, const char *file, int line, const char *func, const char *fmt,...)
 Register a resource with a formatted name, type, and location info (no auto-suffix).
void named_unregister (uintptr_t key)
 Unregister a resource by key.
const char * named_update_name (uintptr_t key, const char *new_base_name)
 Update the registered name for a resource with a new base name.
const char * named_get (uintptr_t key)
 Look up the registered name for a resource.
bool named_registry_has_type (const char *type, size_t length)
const char * named_get_type (uintptr_t key)
 Look up the registered type for a resource.
const char * named_get_format_spec (uintptr_t key)
 Get the format specifier for a registered named object.
const char * named_describe (uintptr_t key, const char *type_hint)
 Format a description string for logging.
const char * named_describe_thread (void *thread)
 Describe a thread for logging (function wrapper).
asciichat_error_t named_registry_for_each (named_iter_callback_t callback, void *user_data, bool *completed)
 Iterate through all registered entries.
asciichat_error_t named_registry_try_snapshot (size_t capacity, size_t *required, bool *completed, named_snapshot_fn copy, void *data)
bool named_registry_read (uintptr_t key, const char *type, void(*read_object)(uintptr_t, void *), void *user_data)
const char * named_search_by_type_id (const char *type, void *id)
bool named_fd_metadata_copy (int fd, named_metadata_t *output)
bool named_packet_metadata_copy (int packet_type, named_metadata_t *output)
const char * named_register_fd (int fd, const char *name, const char *file, int line, const char *func)
 Register a file descriptor with namespace encoding.
const char * named_get_fd (int fd)
 Look up a registered file descriptor.
const char * named_get_fd_format_spec (int fd)
 Get the format specifier for a registered file descriptor.
const char * named_register_packet_type (int pkt_type, const char *file, int line, const char *func)
 Register a packet type with namespace encoding.
const char * named_get_packet_type (int pkt_type)
 Look up a registered packet type.
const char * named_get_packet_type_format_spec (int pkt_type)
 Get the format specifier for a registered packet type.
void named_registry_register_packet_types (void)
 Register all packet types from packet_type_t enum.
void named_print_hash_stats (void)

Detailed Description

Named object registry for debugging.

Provides a centralized registry for naming any addressable resource. Uses uthash for O(1) lookup by uintptr_t key. Rwlock protects the hash table with minimal critical section.

Definition in file debug/named.c.

Macro Definition Documentation

◆ DEBUG_NAMED_FINAL_BASE_NAME_BUFFER_SIZE

#define DEBUG_NAMED_FINAL_BASE_NAME_BUFFER_SIZE   256

Definition at line 12 of file debug/named.c.

Referenced by named_register().

◆ DESCRIBE_BUFFER_SIZE

#define DESCRIBE_BUFFER_SIZE   768

Definition at line 38 of file debug/named.c.

Referenced by named_describe().

◆ MAX_NAME_LEN

#define MAX_NAME_LEN   256

Definition at line 37 of file debug/named.c.

Referenced by named_registry_for_each(), and named_update_name().

◆ uthash_free

#define uthash_free ( ptr,
sz )
Value:
free(ptr)

Definition at line 35 of file debug/named.c.

◆ uthash_malloc

#define uthash_malloc ( sz)
Value:
malloc(sz)

Definition at line 34 of file debug/named.c.

Typedef Documentation

◆ named_entry_t

typedef struct named_entry named_entry_t

Registry entry for uthash.

Function Documentation

◆ named_search_by_type_id()

const char * named_search_by_type_id ( const char * type,
void * id )

Definition at line 698 of file debug/named.c.

698 {
699 (void)type;
700 (void)id;
701 return NULL;
702}