ua_util.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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 <assert.h> // assert
  7. #include "ua_types.h"
  8. /* Debug macros */
  9. #define DBG_VERBOSE(expression) // omit debug code
  10. #define DBG_ERR(expression) // omit debug code
  11. #define DBG(expression) // omit debug code
  12. #if defined(DEBUG) // --enable-debug=(yes|verbose)
  13. # undef DBG
  14. # define DBG(expression) expression
  15. # undef DBG_ERR
  16. # define DBG_ERR(expression) expression
  17. # if defined(VERBOSE) // --enable-debug=verbose
  18. # undef DBG_VERBOSE
  19. # define DBG_VERBOSE(expression) expression
  20. # endif
  21. #endif
  22. /* Global Variables */
  23. extern UA_ByteString UA_ByteString_securityPoliceNone;
  24. void const *UA_alloc_lastptr;
  25. /* Heap memory functions */
  26. #define UA_NULL ((void *)0)
  27. UA_Int32 _UA_free(void *ptr, char *pname, char *f, UA_Int32 l);
  28. UA_Int32 _UA_alloc(void **ptr, UA_Int32 size, char *pname, char *sname, char *f, UA_Int32 l);
  29. UA_Int32 UA_memcpy(void *dst, void const *src, UA_Int32 size);
  30. UA_Int32 UA_VTable_isValidType(UA_Int32 type);
  31. #define UA_free(ptr) _UA_free(ptr, # ptr, __FILE__, __LINE__)
  32. #define UA_alloc(ptr, size) _UA_alloc(ptr, size, # ptr, # size, __FILE__, __LINE__)
  33. #define UA_assert(ignore) assert(ignore)
  34. #endif /* UA_UTILITY_H_ */