00001
00013 #ifndef NEWTMEM_H
00014 #define NEWTMEM_H
00015
00016
00017
00018 #include "NewtType.h"
00019
00020
00021
00022
00024 typedef struct {
00025 void * pool;
00026
00027 int32_t usesize;
00028 int32_t maxspace;
00029 int32_t expandspace;
00030
00031 newtObjRef obj;
00032 newtObjRef literal;
00033 } newtpool_t;
00034
00035 typedef newtpool_t * newtPool;
00036
00037
00039 typedef struct {
00040 newtPool pool;
00041
00042 void * stackp;
00043 uint32_t sp;
00044
00045 uint32_t datasize;
00046 uint32_t nums;
00047 uint32_t blocksize;
00048 } newtStack;
00049
00050
00051
00052
00053 #ifdef __cplusplus
00054 extern "C" {
00055 #endif
00056
00057
00058 newtPool NewtPoolAlloc(int32_t expandspace);
00059
00060 void * NewtMemAlloc(newtPool pool, size_t size);
00061 void * NewtMemCalloc(newtPool pool, size_t number, size_t size);
00062 void * NewtMemRealloc(newtPool pool, void * ptr, size_t size);
00063 void NewtMemFree(void * ptr);
00064
00065 void NewtStackSetup(newtStack * stackinfo,
00066 newtPool pool, uint32_t datasize, uint32_t blocksize);
00067
00068 bool NewtStackExpand(newtStack * stackinfo, uint32_t n);
00069 void NewtStackSlim(newtStack * stackinfo, uint32_t n);
00070 void NewtStackFree(newtStack * stackinfo);
00071
00072 uint32_t NewtAlign(uint32_t n, uint16_t byte);
00073
00074
00075 #ifdef __cplusplus
00076 }
00077 #endif
00078
00079
00080 #endif
00081
00082