fuzz_helpers.c 772 B

123456789101112131415161718192021222324252627282930313233
  1. /*
  2. * Copyright (c) 2016-2021, Facebook, Inc.
  3. * All rights reserved.
  4. *
  5. * This source code is licensed under both the BSD-style license (found in the
  6. * LICENSE file in the root directory of this source tree) and the GPLv2 (found
  7. * in the COPYING file in the root directory of this source tree).
  8. * You may select, at your option, one of the above-listed licenses.
  9. */
  10. #include "fuzz_helpers.h"
  11. #include <stddef.h>
  12. #include <stdlib.h>
  13. #include <string.h>
  14. void* FUZZ_malloc(size_t size)
  15. {
  16. if (size > 0) {
  17. void* const mem = malloc(size);
  18. FUZZ_ASSERT(mem);
  19. return mem;
  20. }
  21. return NULL;
  22. }
  23. int FUZZ_memcmp(void const* lhs, void const* rhs, size_t size)
  24. {
  25. if (size == 0) {
  26. return 0;
  27. }
  28. return memcmp(lhs, rhs, size);
  29. }