spires_reservoir_destroy
Free all memory associated with a reservoir.
Signature
void spires_reservoir_destroy(spires_reservoir *r);Parameters
| Parameter | Type | Description |
|---|---|---|
r | spires_reservoir * | Handle to the reservoir to destroy. May be NULL, in which case the call is a no-op. |
Returns
This function returns void.
Example
spires_reservoir *r = NULL;
spires_reservoir_create(&cfg, &r);
/* ... use reservoir ... */
spires_reservoir_destroy(r);
r = NULL; /* good practice: avoid dangling pointer */Notes
- NULL safety. Passing
NULLis explicitly permitted and results in no action. This mirrors the behavior offree(NULL)in the C standard library and simplifies cleanup code paths. - Double-free. Calling
spires_reservoir_destroytwice on the same non-NULLpointer is undefined behavior. Set the pointer toNULLafter destruction to prevent accidental reuse. - Ownership. This function releases all internal allocations made by
spires_reservoir_create, including the internal weight matrices, state vectors, and readout weights. It does not free any memory that was allocated by the caller (e.g., the originalspires_reservoir_configor itsneuron_params). - Thread safety. Do not call this function on a reservoir that is concurrently being used by another thread.
See Also
- spires_reservoir_create — allocate a reservoir.
- spires_reservoir_reset — reset without freeing.
- Memory Management — ownership conventions.
Last updated on