Source code of Windows XP (NT5)
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.

47 lines
784 B

  1. // Copyright (c) 1993-1999 Microsoft Corporation
  2. #pragma warning ( disable : 4514 )
  3. #include "nulldefs.h"
  4. #include <stdlib.h>
  5. #include <string.h>
  6. #include <malloc.h>
  7. #include "common.hxx"
  8. #include "errors.hxx"
  9. unsigned long TotalAllocation;
  10. void * AllocateNew(
  11. size_t size )
  12. {
  13. void * _last_allocation;
  14. if( (_last_allocation = malloc( size )) == 0 )
  15. {
  16. RpcError( 0,
  17. 0,
  18. OUT_OF_MEMORY,
  19. 0 );
  20. exit( OUT_OF_MEMORY );
  21. }
  22. TotalAllocation += size;
  23. return _last_allocation;
  24. }
  25. void AllocateDelete( void * p )
  26. {
  27. if( p )
  28. free( (char *)p );
  29. }
  30. char * MIDLStrDup( char *p )
  31. {
  32. if (NULL == p)
  33. return p;
  34. return strcpy( new char[ strlen(p) + sizeof('\0') ], p );
  35. }