Windows2003-3790/multimedia/media/mplayer2/alloc.c
2020-09-30 16:53:55 +02:00

77 lines
1.5 KiB
C
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/* ---File: alloc.c -------------------------------------------------------
*
* Description:
* Contains memory allocation routines.
*
* This document contains confidential/proprietary information.
* Copyright (c) 1990-1994 Microsoft Corporation, All Rights Reserved.
*
* Revision History:
*
* ---------------------------------------------------------------------- */
/* Notes -
Global Functions:
AllocMem () -
AllocStr () -
FreeMem () -
FreeStr () -
ReallocMem () -
*/
#include <windows.h>
#include "mplayer.h"
LPTSTR AllocStr( LPTSTR lpStr )
/*++
Routine Description:
This function will allocate enough local memory to store the specified
string, and copy that string to the allocated memory
Arguments:
lpStr - Pointer to the string that needs to be allocated and stored
Return Value:
NON-NULL - A pointer to the allocated memory containing the string
FALSE/NULL - The operation failed. Extended error status is available
using GetLastError.
--*/
{
LPTSTR lpMem;
if( !lpStr )
return NULL;
lpMem = AllocMem( STRING_BYTE_COUNT( lpStr ) );
if( lpMem )
lstrcpy( lpMem, lpStr );
return lpMem;
}
VOID FreeStr( LPTSTR lpStr )
{
FreeMem( lpStr, STRING_BYTE_COUNT( lpStr ) );
}
VOID ReallocStr( LPTSTR *plpStr, LPTSTR lpStr )
{
FreeStr( *plpStr );
*plpStr = AllocStr( lpStr );
}