From 68be10f11be6098f5cb19bf373e2c6ff82f93c71 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Fri, 9 May 2014 14:00:42 -0400 Subject: object: Get rid of void *ptr field. Instead, allow dmnsn_object to be embedded in a larger struct. This gives a consistent 1% speed boost. --- libdimension/dimension/object.h | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'libdimension/dimension') diff --git a/libdimension/dimension/object.h b/libdimension/dimension/object.h index 28cc266..4d75582 100644 --- a/libdimension/dimension/object.h +++ b/libdimension/dimension/object.h @@ -1,5 +1,5 @@ /************************************************************************* - * Copyright (C) 2009-2011 Tavian Barnes * + * Copyright (C) 2009-2014 Tavian Barnes * * * * This file is part of The Dimension Library. * * * @@ -67,6 +67,12 @@ typedef bool dmnsn_object_intersection_fn(const dmnsn_object *object, typedef bool dmnsn_object_inside_fn(const dmnsn_object *object, dmnsn_vector point); +/** + * Object destruction callback. + * @param[in] object The object to delete. + */ +typedef void dmnsn_object_free_fn(dmnsn_object *object); + /** An object. */ struct dmnsn_object { dmnsn_texture *texture; /**< Surface properties. */ @@ -85,9 +91,7 @@ struct dmnsn_object { dmnsn_object_initialize_fn *initialize_fn; /**< Initialization callback. */ dmnsn_object_intersection_fn *intersection_fn; /**< Intersection callback. */ dmnsn_object_inside_fn *inside_fn; /**< Inside callback. */ - dmnsn_free_fn *free_fn; /**< Destruction callback. */ - - void *ptr; /**< Generic pointer for object info. */ + dmnsn_object_free_fn *free_fn; /**< Destruction callback. */ DMNSN_REFCOUNT; /**< Reference count. */ bool initialized; /**< @internal Whether the object is initialized yet. */ @@ -99,6 +103,12 @@ struct dmnsn_object { */ dmnsn_object *dmnsn_new_object(void); +/** + * Initialize a dmnsn_object field. + * @param[in,out] object The object to initialize. + */ +void dmnsn_init_object(dmnsn_object *object); + /** * Free an object * @param[in,out] object The object to destroy. -- cgit v1.2.3