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.

66 lines
1.7 KiB

  1. //================================================================================
  2. // Copyright (C) 1997 Microsoft Corporation
  3. // Author: RameshV
  4. // Description: implements the basic structures for an option
  5. // ThreadSafe: no
  6. // Locks: none
  7. // Please read stdinfo.txt for programming style.
  8. //================================================================================
  9. #include <mm.h>
  10. //BeginExport(typedef)
  11. typedef struct _M_OPTION {
  12. DWORD OptId;
  13. DWORD Len;
  14. BYTE Val[0];
  15. } M_OPTION, *PM_OPTION, *LP_MOPTION;
  16. //EndExport(typedef)
  17. //BeginExport(inline)
  18. DWORD _inline
  19. MemOptInit(
  20. OUT PM_OPTION *Opt,
  21. IN DWORD OptId,
  22. IN DWORD Len,
  23. IN LPBYTE Val
  24. ) {
  25. AssertRet(Opt, ERROR_INVALID_PARAMETER);
  26. AssertRet(Len || NULL==Val, ERROR_INVALID_PARAMETER);
  27. AssertRet(0 == Len|| Val, ERROR_INVALID_PARAMETER);
  28. (*Opt) = MemAlloc(sizeof(M_OPTION)+Len);
  29. if( NULL == (*Opt) ) return ERROR_NOT_ENOUGH_MEMORY;
  30. (*Opt)->OptId = OptId;
  31. (*Opt)->Len = Len;
  32. memcpy((*Opt)->Val, Val, Len);
  33. return ERROR_SUCCESS;
  34. }
  35. //EndExport(inline)
  36. //BeginExport(inline)
  37. DWORD _inline
  38. MemOptCleanup(
  39. IN OUT PM_OPTION Opt
  40. ) {
  41. AssertRet(Opt, ERROR_INVALID_PARAMETER);
  42. MemFree(Opt);
  43. return ERROR_SUCCESS;
  44. }
  45. //EndExport(inline)
  46. //BeginExport(inline)
  47. LPBYTE _inline
  48. MemOptVal(
  49. IN PM_OPTION Opt
  50. ) {
  51. return Opt->Val;
  52. }
  53. //EndExport(inline)
  54. //================================================================================
  55. // end of file
  56. //================================================================================