aux/util: Add function to free device and stuff hanging off it

This commit is contained in:
Jakob Bornecrantz 2019-10-24 11:43:01 +01:00 committed by Jakob Bornecrantz
parent 9b6625961a
commit b67d65b4a5
2 changed files with 24 additions and 0 deletions

View file

@ -273,3 +273,17 @@ u_device_allocate(enum u_device_alloc_flags flags,
return xdev;
}
void
u_device_free(struct xrt_device *xdev)
{
if (xdev->hmd != NULL) {
free(xdev->hmd->distortion.mesh.vertices);
xdev->hmd->distortion.mesh.vertices = NULL;
free(xdev->hmd->distortion.mesh.indices);
xdev->hmd->distortion.mesh.indices = NULL;
}
free(xdev);
}

View file

@ -80,6 +80,8 @@ u_device_dump_config(struct xrt_device *xdev,
* placed after the device in memory.
*
* Will setup any pointers and num values.
*
* @ingroup aux_util
*/
void *
u_device_allocate(enum u_device_alloc_flags flags,
@ -87,6 +89,14 @@ u_device_allocate(enum u_device_alloc_flags flags,
size_t num_inputs,
size_t num_outputs);
/*!
* Helper function to free a device and any data hanging of it.
*
* @ingroup aux_util
*/
void
u_device_free(struct xrt_device *xdev);
#ifdef __cplusplus
}