This content is archived and may be deprecated or obsolete and is presented in the hope that it may still be useful.
MAlloc
MAlloc ( Source | Full Release )
MAlloc 1.11 (C) 2006,2009 Jon Ripley Installation ============ To install the MAlloc library copy the files MAlloc.bbc and MAlloc.txt into the BBC BASIC for Windows LIB directory, this should be "C:\Program Files\BBC BASIC for Windows\LIB" if you have installed BBC BASIC for Windows in the default installation directory. If you wish to remove this library you should delete these two files. Usage ===== To make use of the functions in this library in your own programs you should add the following lines to the initialisation routine. INSTALL @lib$+"MAlloc.bbc" Interface ========= DEF FNm_alloc(size%) -------------------- Allocates a block of memory, returning a pointer to the start of memory, or zero if the allocation failed. Usage example: mem% = FNm_alloc(size%) DEF FNm_zalloc(size%) --------------------- Allocates a block of memory, returning a pointer to the start of memory, or zero if the allocation failed. The contents of the allocated memory is initialised to all zeros. Usage example: mem% = FNm_zalloc(size%) DEF PROCm_free(RETURN mem%) --------------------------- De-allocates a block of memory allocated with FNm_alloc or FNm_zalloc, the pointer (mem%) is set to zero. Usage example: PROCm_free(mem%) DEF FNm_realloc(mem%, size%) ---------------------------- Resizes a block of memory previously allcoated by FNm_alloc, FNm_zalloc or FNm_realloc. The new size is specified by size%. Usage example: mem% = FNm_realloc(mem%, size%) Credits ------- Thanks due to Richard Russell for suggesting some shorter code. Changelog --------- 1.11 Fixed a bug in m_realloc