Collection of tools useful for audio production
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

106 lines
2.6KB

  1. /* -*- Mode: C ; c-basic-offset: 2 -*- */
  2. /*****************************************************************************
  3. *
  4. * Non-sleeping memory allocation
  5. *
  6. * Copyright (C) 2006,2007 Nedko Arnaudov <nedko@arnaudov.name>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; version 2 of the License
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20. *
  21. *****************************************************************************/
  22. #ifndef MEMORY_ATOMIC_H__7B572547_304D_4597_8808_990BE4476CC3__INCLUDED
  23. #define MEMORY_ATOMIC_H__7B572547_304D_4597_8808_990BE4476CC3__INCLUDED
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. #if 0
  28. } /* Adjust editor indent */
  29. #endif
  30. typedef void * rtsafe_memory_pool_handle;
  31. /* will sleep */
  32. int
  33. rtsafe_memory_pool_create(
  34. size_t data_size, /* chunk size */
  35. size_t min_preallocated, /* min chunks preallocated */
  36. size_t max_preallocated, /* max chunks preallocated */
  37. rtsafe_memory_pool_handle * pool_ptr);
  38. /* will sleep */
  39. void
  40. rtsafe_memory_pool_destroy(
  41. rtsafe_memory_pool_handle pool);
  42. /* may sleep */
  43. void
  44. rtsafe_memory_pool_sleepy(
  45. rtsafe_memory_pool_handle pool);
  46. /* will not sleep, returns NULL if no memory is available */
  47. void *
  48. rtsafe_memory_pool_allocate(
  49. rtsafe_memory_pool_handle pool);
  50. /* may sleep */
  51. void *
  52. rtsafe_memory_pool_allocate_sleepy(
  53. rtsafe_memory_pool_handle pool);
  54. /* will not sleep */
  55. void
  56. rtsafe_memory_pool_deallocate(
  57. rtsafe_memory_pool_handle pool,
  58. void * data);
  59. typedef void * rtsafe_memory_handle;
  60. /* will sleep */
  61. int
  62. rtsafe_memory_init(
  63. size_t max_size,
  64. size_t prealloc_min,
  65. size_t prealloc_max,
  66. rtsafe_memory_handle * handle_ptr);
  67. /* will not sleep */
  68. void *
  69. rtsafe_memory_allocate(
  70. rtsafe_memory_handle handle_ptr,
  71. size_t size);
  72. void
  73. rtsafe_memory_sleepy(
  74. rtsafe_memory_handle handle_ptr);
  75. /* will not sleep */
  76. void
  77. rtsafe_memory_deallocate(
  78. void * data);
  79. void
  80. rtsafe_memory_uninit(
  81. rtsafe_memory_handle handle_ptr);
  82. #if 0
  83. { /* Adjust editor indent */
  84. #endif
  85. #ifdef __cplusplus
  86. } /* extern "C" */
  87. #endif
  88. #endif /* #ifndef MEMORY_ATOMIC_H__7B572547_304D_4597_8808_990BE4476CC3__INCLUDED */