ascii-chat 0.11.33
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 uthash_malloc(sz)   malloc(sz)
 
#define uthash_free(ptr, sz)   free(ptr)
 
#define MAX_NAME_LEN   256
 
#define DESCRIBE_BUFFER_SIZE   768
 

Typedefs

typedef struct named_entry named_entry_t
 Registry entry for uthash.
 

Functions

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.
 
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)
 
void named_registry_for_each (named_iter_callback_t callback, void *user_data)
 Iterate through all registered entries.
 
const char * named_search_by_type_id (const char *type, void *id)
 
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.
 

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

◆ DESCRIBE_BUFFER_SIZE

#define DESCRIBE_BUFFER_SIZE   768

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

◆ MAX_NAME_LEN

#define MAX_NAME_LEN   256

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

◆ uthash_free

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

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

◆ uthash_malloc

#define uthash_malloc (   sz)    malloc(sz)

Definition at line 28 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 438 of file debug/named.c.

438 {
439 (void)type;
440 (void)id;
441 return NULL;
442}