12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- /*
- * malloc.h
- *
- * Copyright (C) 2019 Aleksandar Andrejevic <theflash@sdf.lonestar.org>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- #include "mlcrt.h"
- #ifndef _MALLOC_H_
- #define _MALLOC_H_
- #define __CRT_HEAP_FLAG_READY (1 << 0)
- #define __CRT_HEAP_FLAG_ZEROFILL (1 << 1)
- #define __CRT_HEAP_FLAG_BESTFIT (1 << 2)
- enum
- {
- __CRT_HEAP_CORRUPTED,
- __CRT_HEAP_DOUBLE_FREE,
- __CRT_HEAP_BAD_POINTER,
- __CRT_HEAP_OUT_OF_MEMORY,
- };
- typedef struct
- {
- uint32_t magic;
- void *base;
- size_t size;
- uint32_t flags;
- uintptr_t next_offset;
- void *mutex;
- void (*lock_mutex_proc)(void*);
- void (*unlock_mutex_proc)(void*);
- void (*problem)(int);
- } __CRT_PRIVATE(heap_t);
- void *__CRT_PUBLIC(malloc)(size_t size);
- void __CRT_PUBLIC(free)(void *ptr);
- void *__CRT_PUBLIC(calloc)(size_t nmemb, size_t size);
- void *__CRT_PUBLIC(realloc)(void *ptr, size_t size);
- #endif
|