ua_util.h 920 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #ifndef UA_UTIL_H_
  2. #define UA_UTIL_H_
  3. #ifndef __USE_POSIX
  4. #define __USE_POSIX
  5. #endif
  6. #include <stdlib.h> // malloc, free
  7. #include <string.h> // memcpy
  8. #include <assert.h> // assert
  9. #ifdef _WIN32
  10. # include <malloc.h>
  11. #else
  12. # include <alloca.h>
  13. #endif
  14. #include "ua_types.h"
  15. #define UA_NULL ((void *)0)
  16. // subtract from nodeids to get from the encoding to the content
  17. #define UA_ENCODINGOFFSET_XML 1
  18. #define UA_ENCODINGOFFSET_BINARY 2
  19. #define UA_assert(ignore) assert(ignore)
  20. /* Replace the macros with functions for custom allocators if necessary */
  21. #define UA_free(ptr) free(ptr)
  22. #define UA_malloc(size) malloc(size)
  23. #define UA_realloc(ptr, size) realloc(ptr, size)
  24. #define UA_memcpy(dst, src, size) memcpy(dst, src, size)
  25. #define UA_memset(ptr, value, size) memset(ptr, value, size)
  26. #ifdef _WIN32
  27. # define UA_alloca(SIZE) _alloca(SIZE)
  28. #else
  29. # define UA_alloca(SIZE) alloca(SIZE)
  30. #endif
  31. #endif /* UA_UTIL_H_ */