mjsonrpc 1.0
A lightweight JSON-RPC 2.0 message parser and generator based on cJSON
Loading...
Searching...
No Matches
Functions
Handle Management Functions

Functions for creating and managing RPC handles. More...

Functions

mjrpc_handle_tmjrpc_create_handle (size_t initial_capacity)
 Create a new JSON-RPC handle.
 
int mjrpc_destroy_handle (mjrpc_handle_t *handle)
 Destroy a JSON-RPC handle and free all associated memory.
 

Detailed Description

Functions for creating and managing RPC handles.

Function Documentation

◆ mjrpc_create_handle()

mjrpc_handle_t * mjrpc_create_handle ( size_t  initial_capacity)

Create a new JSON-RPC handle.

Allocates and initializes a new mjrpc_handle_t structure with the specified initial capacity for the internal hash table.

Parameters
initial_capacityInitial capacity of the hash table (0 for default)
Returns
Pointer to the created handle (caller must destroy)
Return values
NULLIf memory allocation failed
Note
If initial_capacity is 0, a default capacity will be used
The handle must be destroyed with mjrpc_destroy_handle() to prevent memory leaks
Example:
if (handle) {
// Use handle...
}
int mjrpc_destroy_handle(mjrpc_handle_t *handle)
Destroy a JSON-RPC handle and free all associated memory.
mjrpc_handle_t * mjrpc_create_handle(size_t initial_capacity)
Create a new JSON-RPC handle.
Main handle structure for managing RPC methods.
Definition mjsonrpc.h:175

◆ mjrpc_destroy_handle()

int mjrpc_destroy_handle ( mjrpc_handle_t handle)

Destroy a JSON-RPC handle and free all associated memory.

Destroys the specified handle, freeing all registered method names, arguments, and the handle structure itself.

Parameters
handleHandle to be destroyed (can be NULL)
Returns
Error code from enum mjrpc_error_return
Return values
MJRPC_RET_OKIf successful
MJRPC_RET_ERROR_HANDLE_NOT_INITIALIZEDIf handle is NULL
Example:
// ... use handle ...
int ret = mjrpc_destroy_handle(handle);
if (ret != MJRPC_RET_OK) {
// Handle error...
}
@ MJRPC_RET_OK
Operation completed successfully.
Definition mjsonrpc.h:87