home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
kermit.columbia.edu
/
kermit.columbia.edu.tar
/
kermit.columbia.edu
/
tmp9
/
p_omalloc.c
< prev
next >
Wrap
C/C++ Source or Header
|
2002-01-20
|
2KB
|
91 lines
/*****************************************************************************/
/* */
/* Copyright (c) 1995 by Oy Online Solutions Ltd. */
/* */
/* Distribution of this source code is strictly forbbidden. Use of this */
/* source code is granted to the University of Columbia C-Kermit project */
/* to be distributed in binary format only. Please familiarize yourself */
/* with the accompanying LICENSE.P file. */
/* */
/*****************************************************************************/
/* More friendlier interface to OS/2's DosAllocMem and DosFreeMem API calls */
#include "ckcdeb.h"
#ifndef NOXFER
#ifdef OS2
#ifdef NT
#include <windows.h>
#else /* NT */
#define INCL_DOSMEMMGR
#include <os2.h>
#undef COMMENT
#endif /* NT */
#else /* OS2 */
#include <stdlib.h>
#endif /* OS2 */
#include "p.h"
#include "p_type.h"
#include "p_error.h"
VOID
#ifdef CK_ANSIC
p_omalloc(void **buf, U32 size, U32 module, U32 line)
#else
p_omalloc(buf,size,module,line)
void **buf; U32 size; U32 module; U32 line;
#endif
{
APIRET rc=0;
if ( buf == NULL )
return;
#ifdef OS2
#ifdef NT
*buf = GlobalAlloc( 0, size ) ;
if ( !buf ) rc = GetLastError() ;
#else /* NT */
rc = DosAllocMem(buf, size, PAG_COMMIT | PAG_WRITE | PAG_READ);
#endif /* NT */
#else /* OS2 */
*buf = malloc(size);
if ( !*buf ) rc = 1 ;
#endif /* OS2 */
if (rc)
os2_error(P_ERROR_DOSALLOCMEM, rc, module, line, NULL);
}
VOID
#ifdef CK_ANSIC
p_ofree(void **buf, U32 module, U32 line)
#else
p_ofree(buf, module,line)
void **buf; U32 module; U32 line;
#endif
{
APIRET rc=0;
if ( *buf == NULL )
return;
#ifdef OS2
#ifdef NT
if ( GlobalFree(*buf) )
rc = GetLastError() ;
#else /* NT */
rc = DosFreeMem(*buf);
#endif /* NT */
#else /* OS2 */
rc = free(*buf);
#endif /* OS2 */
if (rc)
os2_error(P_ERROR_DOSFREEMEM, rc, module, line, 0);
*buf = NULL;
}
#endif /* NOXFER */