blob: a7602b255576d3cc27ddf45907f8f29aa7565502 [file] [log] [blame]
// Copyright 2016 The Fuchsia Authors
// Copyright (c) 2008-2015 Travis Geiselbrecht
//
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT
#pragma once
#include <stddef.h>
#include <sys/types.h>
#include <zircon/compiler.h>
__BEGIN_CDECLS
// standard heap definitions
void *malloc(size_t size) __MALLOC;
void *memalign(size_t boundary, size_t size) __MALLOC;
void *calloc(size_t count, size_t size) __MALLOC;
void *realloc(void *ptr, size_t size);
void free(void *ptr);
// alternate versions where the caller is passed in
void *malloc_debug_caller(size_t size, void *caller) __MALLOC;
void heap_init(void);
// tell the heap to return any free pages it can find
void heap_trim(void);
// internal apis used by the heap implementation to get/return pages to the VM
void *heap_page_alloc(size_t pages);
void heap_page_free(void *ptr, size_t pages);
// Gets stats about the heap.
// |size_bytes| is the total size of the heap, |free_bytes| is the free portion.
void heap_get_info(size_t *size_bytes, size_t *free_bytes);
__END_CDECLS