/**
- * Utility function to check whether a requested alignment is consistent with
- * the provided alignment or not.
+ * Utility function to check whether the provided alignment is consistent with
+ * the requested or not.
*/
-static INLINE int
+static INLINE boolean
pb_check_alignment(size_t requested, size_t provided)
{
- return requested <= provided && (provided % requested) == 0;
+ return requested <= provided && (provided % requested) == 0 ? TRUE : FALSE;
+}
+
+
+/**
+ * Utility function to check whether the provided alignment is consistent with
+ * the requested or not.
+ */
+static INLINE boolean
+pb_check_usage(unsigned requested, unsigned provided)
+{
+ return (requested & provided) == provided ? TRUE : FALSE;
}
{
struct fenced_buffer_list *fenced_list;
- fenced_list = (struct fenced_buffer_list *)CALLOC(1, sizeof(*fenced_list));
+ fenced_list = CALLOC_STRUCT(fenced_buffer_list);
if (!fenced_list)
return NULL;
{
struct pb_alt_manager *mgr;
+ if(!provider1 || !provider2)
+ return NULL;
+
mgr = CALLOC_STRUCT(pb_alt_manager);
if (!mgr)
return NULL;
if(!pb_check_alignment(desc->alignment, buf->base.base.alignment))
return FALSE;
- /* XXX: check usage too? */
+ if(!pb_check_usage(desc->usage, buf->base.base.usage))
+ return FALSE;
return TRUE;
}
assert(buf->buffer->base.refcount >= 1);
assert(pb_check_alignment(desc->alignment, buf->buffer->base.alignment));
- assert((buf->buffer->base.usage & desc->usage) == desc->usage);
+ assert(pb_check_usage(desc->usage, buf->buffer->base.usage));
assert(buf->buffer->base.size >= size);
buf->base.base.refcount = 1;
{
struct pb_cache_manager *mgr;
- mgr = (struct pb_cache_manager *)CALLOC(1, sizeof(*mgr));
+ if(!provider)
+ return NULL;
+
+ mgr = CALLOC_STRUCT(pb_cache_manager);
if (!mgr)
return NULL;
if(!provider)
return NULL;
- fenced_mgr = (struct fenced_pb_manager *)CALLOC(1, sizeof(*fenced_mgr));
+ fenced_mgr = CALLOC_STRUCT(fenced_pb_manager);
if (!fenced_mgr)
return NULL;
* \file
* Buffer manager using the old texture memory manager.
*
- * \author José Fonseca <jrfonseca@tungstengraphics.com>
+ * \author José Fonseca <jrfonseca@tungstengraphics.com>
*/
struct pb_manager *mgr;
struct pb_desc desc;
- assert(provider);
- assert(provider->create_buffer);
+ if(!provider)
+ return NULL;
memset(&desc, 0, sizeof(desc));
desc.alignment = 1 << align2;
* \file
* Batch buffer pool management.
*
- * \author José Fonseca <jrfonseca-at-tungstengraphics-dot-com>
- * \author Thomas Hellström <thomas-at-tungstengraphics-dot-com>
+ * \author José Fonseca <jrfonseca-at-tungstengraphics-dot-com>
+ * \author Thomas Hellström <thomas-at-tungstengraphics-dot-com>
*/
struct pool_buffer *pool_buf;
size_t i;
- pool = (struct pool_pb_manager *)CALLOC(1, sizeof(*pool));
+ if(!provider)
+ return NULL;
+
+ pool = CALLOC_STRUCT(pool_pb_manager);
if (!pool)
return NULL;
if(!pb_check_alignment(desc->alignment, mgr->bufSize))
return NULL;
- /* XXX: check for compatible buffer usage too? */
-
+ assert(pb_check_usage(desc->usage, mgr->desc.usage));
+ if(!pb_check_usage(desc->usage, mgr->desc.usage))
+ return NULL;
+
_glthread_LOCK_MUTEX(mgr->mutex);
if (mgr->slabs.next == &mgr->slabs) {
(void) pb_slab_create(mgr);
size_t bufSize;
unsigned i;
+ if(!provider)
+ return NULL;
+
mgr = CALLOC_STRUCT(pb_slab_range_manager);
if (!mgr)
goto out_err0;