avoid deref

We can avoid a deref when we use container_of to get from the interface
to the handle.
This commit is contained in:
Wim Taymans 2016-10-12 17:27:29 +02:00
parent 6b3bb79e70
commit 82414810e8
23 changed files with 433 additions and 385 deletions

View file

@ -51,8 +51,6 @@ typedef enum {
* The main processing clocks.
*/
struct _SpaClock {
/* pointer to the handle owning this interface */
SpaHandle *handle;
/* the total size of this clock. This can be used to expand this
* structure in the future */
size_t size;

View file

@ -116,6 +116,46 @@ typedef void (*SpaNotify) (void *data);
# define SPA_PRINTF_FUNC(fmt, arg1)
#endif
#ifndef SPA_LIKELY
#ifdef __GNUC__
#define SPA_LIKELY(x) (__builtin_expect(!!(x),1))
#define SPA_UNLIKELY(x) (__builtin_expect(!!(x),0))
#else
#define SPA_LIKELY(x) (x)
#define SPA_UNLIKELY(x) (x)
#endif
#endif
#define spa_return_if_fail (log, expr) \
do { \
if (SPA_UNLIKELY (!(expr))) { \
spa_log_debug(log, "Assertion '%s' failed\n", #expr); \
return; \
} \
} while(false)
#define spa_return_val_if_fail (log, expr, val) \
do { \
if (SPA_UNLIKELY(!(expr))) { \
spa_log_debug (log, "Assertion '%s' failed\n", #expr); \
return (val); \
} \
} while(false)
/* spa_assert_se() is an assert which guarantees side effects of x,
* i.e. is never optimized away, regardless of NDEBUG or FASTPATH. */
#define spa_assert_se (expr) \
do { \
if (SPA_UNLIKELY(!(expr))) { \
spa_log_error("Assertion '%s' failed, Aborting\n.", #expr); \
abort(); \
} \
} while (false)
/* Does exactly nothing */
#define spa_nop() do {} while (false)
#ifdef __cplusplus
} /* extern "C" */

View file

@ -98,8 +98,6 @@ typedef void (*SpaMonitorEventCallback) (SpaMonitor *monitor,
* The device monitor interface.
*/
struct _SpaMonitor {
/* pointer to the handle owning this interface */
SpaHandle *handle;
/**
* SpaMonitor::info
*

View file

@ -148,8 +148,6 @@ typedef void (*SpaNodeEventCallback) (SpaNode *node,
* The main processing nodes.
*/
struct _SpaNode {
/* pointer to the handle owning this interface */
SpaHandle *handle;
/* the total size of this node. This can be used to expand this
* structure in the future */
size_t size;