serenity/AK/kmalloc.h
Andreas Kling 25e850ebb1 Kernel: Remove krealloc()
This was only used by a single class (AK::ByteBuffer) in the kernel
and not in an OOM-safe way.

Now that ByteBuffer no longer uses it, there's no need for the kernel
heap to burden itself with supporting this.
2021-07-11 14:14:51 +02:00

50 lines
1.1 KiB
C++

/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2021, Daniel Bertalan <dani@danielbertalan.dev>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#if defined(KERNEL)
# include <Kernel/Heap/kmalloc.h>
#else
# include <new>
# include <stdlib.h>
# define kcalloc calloc
# define kmalloc malloc
# define kmalloc_good_size malloc_good_size
# define kfree free
inline void kfree_sized(void* ptr, size_t)
{
kfree(ptr);
}
#endif
#ifndef __serenity__
# include <AK/Types.h>
# ifndef AK_OS_MACOS
extern "C" {
inline size_t malloc_good_size(size_t size) { return size; }
}
# else
# include <malloc/malloc.h>
# endif
#endif
#ifdef KERNEL
# define AK_MAKE_ETERNAL \
public: \
void* operator new(size_t size) { return kmalloc_eternal(size); } \
\
private:
#else
# define AK_MAKE_ETERNAL
#endif
using std::nothrow;