ua_util.h 1.1 KB

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