acutmem.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright 2015 Autodesk, Inc. All rights reserved.
  4. //
  5. // Use of this software is subject to the terms of the Autodesk license
  6. // agreement provided at the time of installation or download, or which
  7. // otherwise accompanies this software in either electronic or hard copy form.
  8. //
  9. //////////////////////////////////////////////////////////////////////////////
  10. //
  11. // acutmem.h - General memory allocation functions.
  12. //
  13. // DESCRIPTION:
  14. //
  15. // The following functions are used to handle string values and memory
  16. // returned to or from (or passed into) the ObjectARX API. Function
  17. // acutNewString() makes a copy of a string and returns an error status.
  18. // Function acutUpdString() performs the same job as acutNewString(),
  19. // except that it first frees any string already pointed to by the
  20. // output argument. acutDelString() frees up a string allocated by
  21. // acutNewString() or acutUpdString() if the input pointer is non
  22. // NULL and then sets the pointer to NULL.
  23. //
  24. #ifndef _ACUTMEM_H
  25. #define _ACUTMEM_H
  26. #include "acadstrc.h" // Acad::ErrorStatus
  27. #include "AdAChar.h" // ACHAR
  28. #pragma pack (push, 8)
  29. Acad::ErrorStatus acutNewBuffer(void *&pOutput, size_t size);
  30. Acad::ErrorStatus acutNewString(ACHAR *&pOutput, int nNumChars);
  31. Acad::ErrorStatus acutNewString(const ACHAR* pInput, ACHAR*& pOutput);
  32. Acad::ErrorStatus acutUpdString(const ACHAR* pInput, ACHAR*& pOutput);
  33. void acutDelBuffer(void *& pBuffer);
  34. inline Acad::ErrorStatus acutNewBuffer(char *&pOutput, size_t size)
  35. {
  36. return ::acutNewBuffer((void * &)pOutput, size);
  37. }
  38. inline void acutDelBuffer(char *& pString)
  39. {
  40. ::acutDelBuffer((void * &)pString);
  41. }
  42. inline void acutDelString(char *& pString)
  43. {
  44. ::acutDelBuffer((void * &)pString);
  45. }
  46. inline void acutDelString(wchar_t *& pString)
  47. {
  48. ::acutDelBuffer((void * &)pString);
  49. }
  50. #pragma pack (pop)
  51. #endif // _ACUTMEM_H