1 /*$ 2 Copyright (C) 2013-2020 Azel. 3 4 This file is part of AzPainter. 5 6 AzPainter is free software: you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation, either version 3 of the License, or 9 (at your option) any later version. 10 11 AzPainter is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with this program. If not, see <http://www.gnu.org/licenses/>. 18 $*/ 19 20 #ifndef MLIB_MEMAUTO_H 21 #define MLIB_MEMAUTO_H 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif 26 27 typedef struct _mMemAuto 28 { 29 uint8_t *buf; 30 uintptr_t allocsize,curpos,appendsize; 31 }mMemAuto; 32 33 34 void mMemAutoInit(mMemAuto *p); 35 void mMemAutoFree(mMemAuto *p); 36 mBool mMemAutoAlloc(mMemAuto *p,uintptr_t initsize,uintptr_t appendsize); 37 38 void mMemAutoReset(mMemAuto *p); 39 void mMemAutoBack(mMemAuto *p,int size); 40 uintptr_t mMemAutoGetRemain(mMemAuto *p); 41 uint8_t *mMemAutoGetBottom(mMemAuto *p); 42 43 void mMemAutoCutCurrent(mMemAuto *p); 44 45 mBool mMemAutoAppend(mMemAuto *p,void *dat,uintptr_t size); 46 mBool mMemAutoAppendByte(mMemAuto *p,uint8_t dat); 47 mBool mMemAutoAppendZero(mMemAuto *p,int size); 48 49 #ifdef __cplusplus 50 } 51 #endif 52 53 #endif 54