custom_memory_manager.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  4. *
  5. * Copyright 2018 (c) Stefan Profanter, fortiss GmbH
  6. */
  7. #ifndef OPEN62541_CUSTOM_MEMORY_MANAGER_H
  8. #define OPEN62541_CUSTOM_MEMORY_MANAGER_H
  9. #include "ua_types.h"
  10. _UA_BEGIN_DECLS
  11. /**
  12. * Set memory limit for memory manager.
  13. * This allows to reduce the available memory (RAM) for fuzzing tests.
  14. *
  15. * @param maxMemory Available memory in bytes
  16. */
  17. void UA_EXPORT UA_memoryManager_setLimit(unsigned long long maxMemory);
  18. /**
  19. * Extract the memory limit from the last four bytes of the byte array.
  20. * The last four bytes will simply be casted to a uint32_t and that value
  21. * represents the new memory limit.
  22. *
  23. * @param data byte array
  24. * @param size size of the byte array
  25. * @return 1 on success, 0 if the byte array is too short
  26. */
  27. int UA_EXPORT UA_memoryManager_setLimitFromLast4Bytes(const uint8_t *data, size_t size);
  28. _UA_END_DECLS
  29. #endif //OPEN62541_CUSTOM_MEMORY_MANAGER_H