Skip to main content

rgpot_potential_new

Function rgpot_potential_new 

Source
#[unsafe(no_mangle)]
pub unsafe extern "C" fn rgpot_potential_new( callback: PotentialCallback, user_data: *mut c_void, free_fn: Option<unsafe extern "C" fn(*mut c_void)>, ) -> *mut rgpot_potential_t
Expand description

Create a new potential handle from a callback function pointer.

  • callback: the function that performs the force/energy calculation.
  • user_data: opaque pointer forwarded to every callback invocation (typically a pointer to the C++ potential object).
  • free_fn: optional destructor for user_data. Pass NULL if the caller manages the lifetime externally.

Returns a heap-allocated rgpot_potential_t*, or NULL on failure. The caller must eventually pass the returned pointer to rgpot_potential_free.