Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
1.5 KiB

  1. /* ---File: alloc.c -------------------------------------------------------
  2. *
  3. * Description:
  4. * Contains memory allocation routines.
  5. *
  6. * This document contains confidential/proprietary information.
  7. * Copyright (c) 1990-1994 Microsoft Corporation, All Rights Reserved.
  8. *
  9. * Revision History:
  10. *
  11. * ---------------------------------------------------------------------- */
  12. /* Notes -
  13. Global Functions:
  14. AllocMem () -
  15. AllocStr () -
  16. FreeMem () -
  17. FreeStr () -
  18. ReallocMem () -
  19. */
  20. #include <windows.h>
  21. #include "mplayer.h"
  22. LPTSTR AllocStr( LPTSTR lpStr )
  23. /*++
  24. Routine Description:
  25. This function will allocate enough local memory to store the specified
  26. string, and copy that string to the allocated memory
  27. Arguments:
  28. lpStr - Pointer to the string that needs to be allocated and stored
  29. Return Value:
  30. NON-NULL - A pointer to the allocated memory containing the string
  31. FALSE/NULL - The operation failed. Extended error status is available
  32. using GetLastError.
  33. --*/
  34. {
  35. LPTSTR lpMem;
  36. if( !lpStr )
  37. return NULL;
  38. lpMem = AllocMem( STRING_BYTE_COUNT( lpStr ) );
  39. if( lpMem )
  40. lstrcpy( lpMem, lpStr );
  41. return lpMem;
  42. }
  43. VOID FreeStr( LPTSTR lpStr )
  44. {
  45. FreeMem( lpStr, STRING_BYTE_COUNT( lpStr ) );
  46. }
  47. VOID ReallocStr( LPTSTR *plpStr, LPTSTR lpStr )
  48. {
  49. FreeStr( *plpStr );
  50. *plpStr = AllocStr( lpStr );
  51. }
  52.