ua_util.h 1017 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. #include <stddef.h> /* Needed for queue.h */
  10. #ifdef _WIN32
  11. # include <malloc.h>
  12. # include "../deps/queue.h"
  13. #else
  14. # include <alloca.h>
  15. # include <sys/queue.h>
  16. #endif
  17. #include "ua_types.h"
  18. #define UA_NULL ((void *)0)
  19. // subtract from nodeids to get from the encoding to the content
  20. #define UA_ENCODINGOFFSET_XML 1
  21. #define UA_ENCODINGOFFSET_BINARY 2
  22. #define UA_assert(ignore) assert(ignore)
  23. /* Replace the macros with functions for custom allocators if necessary */
  24. #define UA_free(ptr) free(ptr)
  25. #define UA_malloc(size) malloc(size)
  26. #define UA_realloc(ptr, size) realloc(ptr, size)
  27. #define UA_memcpy(dst, src, size) memcpy(dst, src, size)
  28. #define UA_memset(ptr, value, size) memset(ptr, value, size)
  29. #ifdef _WIN32
  30. # define UA_alloca(SIZE) _alloca(SIZE)
  31. #else
  32. # define UA_alloca(SIZE) alloca(SIZE)
  33. #endif
  34. #endif /* UA_UTIL_H_ */