2 * @COPYRIGHT@ Intel Confidential - Unreleased Software
5 #ifndef _OBJECT_HEAP_H_
6 #define _OBJECT_HEAP_H_
8 #define OBJECT_HEAP_OFFSET_MASK 0x7F000000
9 #define OBJECT_HEAP_ID_MASK 0x00FFFFFF
11 typedef struct object_base *object_base_p;
12 typedef struct object_heap *object_heap_p;
28 typedef int object_heap_iterator;
31 * Return 0 on success, -1 on error
33 int object_heap_init( object_heap_p heap, int object_size, int id_offset);
37 * Returns the object ID on success, returns -1 on error
39 int object_heap_allocate( object_heap_p heap );
42 * Lookup an allocated object by object ID
43 * Returns a pointer to the object on success, returns NULL on error
45 object_base_p object_heap_lookup( object_heap_p heap, int id );
48 * Iterate over all objects in the heap.
49 * Returns a pointer to the first object on the heap, returns NULL if heap is empty.
51 object_base_p object_heap_first( object_heap_p heap, object_heap_iterator *iter );
54 * Iterate over all objects in the heap.
55 * Returns a pointer to the next object on the heap, returns NULL if heap is empty.
57 object_base_p object_heap_next( object_heap_p heap, object_heap_iterator *iter );
62 void object_heap_free( object_heap_p heap, object_base_p obj );
65 * Destroys a heap, the heap must be empty.
67 void object_heap_destroy( object_heap_p heap );
69 #endif /* _OBJECT_HEAP_H_ */