ua_util.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. #ifndef UA_UTILITY_H_
  2. #define UA_UTILITY_H_
  3. #include <stdio.h> // printf
  4. #include <stdlib.h> // malloc, free
  5. #include <string.h> // memcpy
  6. #include "ua_types.h"
  7. /* Debug macros */
  8. #define DBG_VERBOSE(expression) // omit debug code
  9. #define DBG_ERR(expression) // omit debug code
  10. #define DBG(expression) // omit debug code
  11. #if defined(DEBUG) // --enable-debug=(yes|verbose)
  12. # undef DBG
  13. # define DBG(expression) expression
  14. # undef DBG_ERR
  15. # define DBG_ERR(expression) expression
  16. # if defined(VERBOSE) // --enable-debug=verbose
  17. # undef DBG_VERBOSE
  18. # define DBG_VERBOSE(expression) expression
  19. # endif
  20. #endif
  21. /* Global Variables */
  22. extern UA_ByteString UA_ByteString_securityPoliceNone;
  23. void const *UA_alloc_lastptr;
  24. /* Heap memory functions */
  25. #define UA_NULL ((void *)0)
  26. UA_Int32 _UA_free(void *ptr, char *pname, char *f, UA_Int32 l);
  27. UA_Int32 _UA_alloc(void **ptr, UA_Int32 size, char *pname, char *sname, char *f, UA_Int32 l);
  28. UA_Int32 UA_memcpy(void *dst, void const *src, UA_Int32 size);
  29. UA_Int32 UA_VTable_isValidType(UA_Int32 type);
  30. #define UA_free(ptr) _UA_free(ptr, # ptr, __FILE__, __LINE__)
  31. #define UA_alloc(ptr, size) _UA_alloc(ptr, size, # ptr, # size, __FILE__, __LINE__)
  32. #endif /* UA_UTILITY_H_ */