Monado OpenXR Runtime
Macros | Functions
oxr_handle.h File Reference

Contains handle-related functions and defines only required in a few locations. More...

#include "oxr_objects.h"
#include <stdlib.h>
Include dependency graph for oxr_handle.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define OXR_ALLOCATE_HANDLE(LOG, OUT, DEBUG, DESTROY, PARENT)
 Allocates memory for a handle and evaluates to an XrResult. More...
 
#define OXR_ALLOCATE_HANDLE_OR_RETURN(LOG, OUT, DEBUG, DESTROY, PARENT)
 Allocate memory for a handle, returning in case of failure. More...
 

Functions

XrResult oxr_handle_init (struct oxr_logger *log, struct oxr_handle_base *hb, uint64_t debug, oxr_handle_destroyer destroy, struct oxr_handle_base *parent)
 Initialize a handle holder, and if a parent is specified, update its child list to include this handle. More...
 
XrResult oxr_handle_allocate_and_init (struct oxr_logger *log, size_t size, uint64_t debug, oxr_handle_destroyer destroy, struct oxr_handle_base *parent, void **out)
 Allocate some memory for use as a handle, and initialize it as a handle. More...
 

Detailed Description

Contains handle-related functions and defines only required in a few locations.

Author
Ryan Pavlik ryan..nosp@m.pavl.nosp@m.ik@co.nosp@m.llab.nosp@m.ora.c.nosp@m.om

Macro Definition Documentation

◆ OXR_ALLOCATE_HANDLE

#define OXR_ALLOCATE_HANDLE (   LOG,
  OUT,
  DEBUG,
  DESTROY,
  PARENT 
)
Value:
oxr_handle_allocate_and_init(LOG, sizeof(*OUT), DEBUG, DESTROY, \
PARENT, (void **)&OUT)
XrResult oxr_handle_allocate_and_init(struct oxr_logger *log, size_t size, uint64_t debug, oxr_handle_destroyer destroy, struct oxr_handle_base *parent, void **out)
Allocate some memory for use as a handle, and initialize it as a handle.
Definition: oxr_handle_base.c:109

Allocates memory for a handle and evaluates to an XrResult.

Parameters
LOGpointer to struct oxr_logger
OUTthe pointer to handle struct type you already created.
DEBUGMagic per-type debugging constant
DESTROYHandle destructor function
PARENTa parent handle, if any

Use when you want to do something other than immediately returning in case of failure. If returning immediately is OK, see OXR_ALLOCATE_HANDLE_OR_RETURN().

◆ OXR_ALLOCATE_HANDLE_OR_RETURN

#define OXR_ALLOCATE_HANDLE_OR_RETURN (   LOG,
  OUT,
  DEBUG,
  DESTROY,
  PARENT 
)
Value:
do { \
XrResult allocResult = \
OXR_ALLOCATE_HANDLE(LOG, OUT, DEBUG, DESTROY, PARENT); \
if (allocResult != XR_SUCCESS) { \
return allocResult; \
} \
} while (0)

Allocate memory for a handle, returning in case of failure.

Parameters
LOGpointer to struct oxr_logger
OUTthe pointer to handle struct type you already created.
DEBUGMagic per-type debugging constant
DESTROYHandle destructor function
PARENTa parent handle, if any

Will return an XrResult from the current function if something fails. If that's not OK, see OXR_ALLOCATE_HANDLE().

Referenced by oxr_action_create(), oxr_action_set_create(), oxr_create_messenger(), oxr_instance_create(), and oxr_space_action_create().

Function Documentation

◆ oxr_handle_allocate_and_init()

XrResult oxr_handle_allocate_and_init ( struct oxr_logger log,
size_t  size,
uint64_t  debug,
oxr_handle_destroyer  destroy,
struct oxr_handle_base parent,
void **  out 
)

Allocate some memory for use as a handle, and initialize it as a handle.

Mainly for internal use - use OXR_ALLOCATE_HANDLE instead which wraps this.

◆ oxr_handle_init()

XrResult oxr_handle_init ( struct oxr_logger log,
struct oxr_handle_base hb,
uint64_t  debug,
oxr_handle_destroyer  destroy,
struct oxr_handle_base parent 
)

Initialize a handle holder, and if a parent is specified, update its child list to include this handle.