Skip to contentSkip to Content
DocsAPI ReferenceLifecyclespires_reservoir_destroy

spires_reservoir_destroy

Free all memory associated with a reservoir.


Signature

void spires_reservoir_destroy(spires_reservoir *r);

Parameters

ParameterTypeDescription
rspires_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 NULL is explicitly permitted and results in no action. This mirrors the behavior of free(NULL) in the C standard library and simplifies cleanup code paths.
  • Double-free. Calling spires_reservoir_destroy twice on the same non-NULL pointer is undefined behavior. Set the pointer to NULL after 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 original spires_reservoir_config or its neuron_params).
  • Thread safety. Do not call this function on a reservoir that is concurrently being used by another thread.

See Also

Last updated on