*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
*/
#include <unistd.h>
+#include <babeltrace/babeltrace-internal.h>
struct ptr_heap {
size_t len, alloc_len;
static inline void *heap_maximum(const struct ptr_heap *heap)
{
check_heap(heap);
- return heap->len ? heap->ptrs[0] : NULL;
+ return likely(heap->len) ? heap->ptrs[0] : NULL;
}
/**
*/
extern void *heap_replace_max(struct ptr_heap *heap, void *p);
+/**
+ * heap_copy - copy a heap
+ * @dst: the destination heap (must be allocated)
+ * @src: the source heap
+ *
+ * Returns -ENOMEM if out of memory.
+ */
+extern int heap_copy(struct ptr_heap *dst, struct ptr_heap *src);
+
#endif /* _BABELTRACE_PRIO_HEAP_H */