tskalloc.cpp
来自「这是一个关于C++编程开发的算法!」· C++ 代码 · 共 59 行
CPP
59 行
/*
CPPTask - A Multitasking Kernel For C++
Version 1.0 08-12-91
Ported by Rich Smith from:
Public Domain Software written by
Thomas Wagner
Patschkauer Weg 31
D-1000 Berlin 33
West Germany
This module contains the memory allocation functions that are needed.
TSKALLOC.CPP - Dynamic memory allocation interface
Subroutines
tsk_alloc
tsk_free
operator new
operator delete
*/
#include "task.hpp"
#include <stdlib.h>
farptr tsk_alloc (word size)
{
farptr ptr;
alloc_resource.request_resource (0L);
ptr = malloc (size);
alloc_resource.release_resource ();
return ptr;
}
void tsk_free (farptr item)
{
alloc_resource.request_resource (0L);
free (item);
alloc_resource.release_resource ();
}
void* operator new(size_t size)
{
return tsk_alloc(size);
}
void operator delete(void* item)
{
tsk_free(item);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?