main.c 908 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * Copyright (C) 2019 Intel Corporation. All rights reserved.
  3. * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. */
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include <assert.h>
  8. void *
  9. test_module_malloc(unsigned buf_size);
  10. void
  11. test_module_free(void *buf);
  12. int
  13. main(int argc, char **argv)
  14. {
  15. char *buf = NULL;
  16. printf("Hello World!\n");
  17. buf = test_module_malloc(1024);
  18. if (buf) {
  19. printf("module_malloc(1024) success, return %p\n", buf);
  20. snprintf(buf, 1024, "%s", "Hello world!\n");
  21. }
  22. else {
  23. printf("module_malloc(1024) failed!\n");
  24. return -1;
  25. }
  26. test_module_free(buf);
  27. buf = test_module_malloc(32 * 1024 * 1024);
  28. if (!buf) {
  29. printf("module_malloc(32MB) failed => expected, not an issue\n");
  30. }
  31. else {
  32. printf("module_malloc(32MB) success, unexpected!\n");
  33. return -1;
  34. }
  35. return 0;
  36. }