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.

112 lines
2.1 KiB

  1. /*++
  2. Copyright (c) 1990,91 Microsoft Corporation
  3. Module Name:
  4. MidlUser.c
  5. Abstract:
  6. This file contains common functions and utilities that the API
  7. DLLs can use in making remote calls. This includes the
  8. MIDL_USER_ALLOCATE functions.
  9. Author:
  10. Dan Lafferty danl 06-Feb-1991
  11. Environment:
  12. User Mode - Win32
  13. Revision History:
  14. 06-Feb-1991 danl
  15. Created
  16. 25-Apr-1991 JohnRo
  17. Split out MIDL user (allocate,free) into seperate source file, so
  18. linker doesn't get confused.
  19. --*/
  20. #include "precomp.h"
  21. #pragma hdrstop
  22. PVOID
  23. MIDL_user_allocate (
  24. IN size_t NumBytes
  25. )
  26. /*++
  27. Routine Description:
  28. Allocates storage for RPC transactions. The RPC stubs will either call
  29. MIDL_user_allocate when it needs to un-marshall data into a buffer
  30. that the user must free. RPC servers will use MIDL_user_allocate to
  31. allocate storage that the RPC server stub will free after marshalling
  32. the data.
  33. Arguments:
  34. NumBytes - The number of bytes to allocate.
  35. Return Value:
  36. none
  37. Note:
  38. --*/
  39. {
  40. #if SPOOLER_HEAP
  41. return (PVOID)HeapAlloc( ghMidlHeap, HEAP_ZERO_MEMORY, NumBytes );
  42. #else
  43. return AllocSplMem(NumBytes);
  44. #endif
  45. }
  46. VOID
  47. MIDL_user_free (
  48. IN void *MemPointer
  49. )
  50. /*++
  51. Routine Description:
  52. Frees storage used in RPC transactions. The RPC client can call this
  53. function to free buffer space that was allocated by the RPC client
  54. stub when un-marshalling data that is to be returned to the client.
  55. The Client calls MIDL_user_free when it is finished with the data and
  56. desires to free up the storage.
  57. The RPC server stub calls MIDL_user_free when it has completed
  58. marshalling server data that is to be passed back to the client.
  59. Arguments:
  60. MemPointer - This points to the memory block that is to be released.
  61. Return Value:
  62. none.
  63. Note:
  64. --*/
  65. {
  66. #if SPOOLER_HEAP
  67. HeapFree( ghMidlHeap, 0, (LPVOID)MemPointer );
  68. #else
  69. FreeSplMem(MemPointer);
  70. #endif
  71. }