alloc_tests.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * SpanDSP - a series of DSP components for telephony
  3. *
  4. * alloc_tests.c - memory allocation handling tests.
  5. *
  6. * Written by Steve Underwood <steveu@coppice.org>
  7. *
  8. * Copyright (C) 2013 Steve Underwood
  9. *
  10. * All rights reserved.
  11. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License version 2, as
  14. * published by the Free Software Foundation.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  24. */
  25. /*! \file */
  26. /*! \page alloc_tests_page Memory allocation tests
  27. \section alloc_tests_page_sec_1 What does it do?
  28. ???.
  29. \section alloc_tests_page_sec_2 How does it work?
  30. ???.
  31. */
  32. #if defined(HAVE_CONFIG_H)
  33. #include "config.h"
  34. #endif
  35. #include <limits.h>
  36. #include <stdio.h>
  37. #include <stdarg.h>
  38. #include <fcntl.h>
  39. #include <stdlib.h>
  40. #include <malloc.h>
  41. #include <inttypes.h>
  42. #include <string.h>
  43. #include <errno.h>
  44. #include <signal.h>
  45. #include <sys/time.h>
  46. #include <time.h>
  47. #include "spandsp.h"
  48. int main(int argc, char *argv[])
  49. {
  50. void *a;
  51. void *b;
  52. void *c;
  53. if (span_mem_allocators(malloc,
  54. realloc,
  55. free,
  56. memalign,
  57. free))
  58. {
  59. printf("Failed\n");
  60. exit(2);
  61. }
  62. a = span_aligned_alloc(8, 42);
  63. b = span_alloc(42);
  64. c = span_realloc(NULL, 42);
  65. printf("%p %p %p\n", a, b, c);
  66. span_aligned_free(a);
  67. span_free(b);
  68. span_free(c);
  69. }
  70. /*- End of function --------------------------------------------------------*/
  71. /*- End of file ------------------------------------------------------------*/