This repository has been archived on 2024-12-16. You can view files and clone it, but cannot push or open issues or pull requests.
CodeBlocksPortable/WATCOM/samples/win/edit/emem.c

57 lines
1.1 KiB
C

#include <windows.h>
#include <malloc.h>
#include <string.h>
#include <stdlib.h>
#include "edit.h"
#if defined( __WINDOWS_386__ ) || defined( __NT__ )
#define amalloc malloc
#define arealloc realloc
#define afree free
#define amemset memset
#else
#define amalloc _fmalloc
#define arealloc _frealloc
#define afree _ffree
#define amemset _fmemset
#endif
/*
* MemAlloc - get some memory
*/
ALLOCPTR MemAlloc( unsigned size )
{
ALLOCPTR ptr;
if( size == 0 ) return( NULL );
ptr = amalloc( size );
if( ptr != NULL ) {
amemset( ptr, 0, size );
} else {
MessageBox( NULL, "Out Of Memory!", EditTitle,
MB_SYSTEMMODAL | MB_OK );
exit( -1 ); /* panic situation */
}
return( ptr );
} /* MemAlloc */
/*
* MemRealloc - reallocate a block
*/
ALLOCPTR MemRealloc( ALLOCPTR ptr, unsigned newsize )
{
return( arealloc( ptr, newsize ) );
} /* MemRealloc */
/*
* MemFree - free some memory
*/
void MemFree( ALLOCPTR ptr )
{
afree( ptr );
} /* MemFree */