memory.c
Sapphire/src/areacon/memory.c · 957 B
From the archive sapphire_0.3.zip
Download the archive « Back to the archive contents
/*
* Copyright (C) 1995-1997 Christopher D. Granz
*
* This header may not be removed.
*
* Refer to the file "License" included in this package for further
* information and before using any of the following.
*/
#include <stdlib.h>
#include <string.h>
#include "areacon.h"
/*
* Functions
*/
void *alloc_mem( register size_t rsMem )
{
register void *pMem;
if ( ( pMem = calloc( 1, rsMem ) ) == NULL )
fatal( "Cannot allocate %ld bytes of memory.\n",
(long) rsMem );
return ( pMem );
}
void free_mem( register void *pMem )
{
if ( pMem == NULL )
return;
free( pMem );
}
char *str_dup( register char *pStr )
{
register int riLen;
if ( pStr == NULL || pStr[0] == '\0' )
return ( "" );
riLen = strlen( pStr );
if ( riLen >= MAX_STRING )
riLen = ( MAX_STRING - 1 );
return ( strncpy( alloc_mem( riLen + 1 ), pStr, riLen ) );
}
/*
* End of memory.c
*/