xref: /haiku/headers/os/media/RealtimeAlloc.h (revision cb3f273dd2ec921b8134f9378a91adb0b2af165b)
1 /*
2  * Copyright 2009, Haiku, Inc. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef _REALTIME_ALLOC_H
6 #define _REALTIME_ALLOC_H
7 
8 
9 #include <SupportDefs.h>
10 
11 
12 /*!	Allocation from separate "pools" of memory. Those pools will be locked
13 	in RAM if realtime allocators are turned on in the BMediaRoster, so don't
14 	waste this memory unless it's needed. Also, the shared pool is a scarce
15 	resource, so it's better if you create your own pool for your own needs
16 	and leave the shared pool for BMediaNode instances and the needs of the
17 	Media Kit.
18 */
19 
20 #if defined(__cplusplus)
21 extern "C" {
22 #endif
23 
24 typedef struct rtm_pool rtm_pool;
25 
26 /* If out_pool is NULL, the default pool will be created if it isn't */
27 /* already. */
28 /* If the default pool is already created, it will return EALREADY. */
29 #if defined(__cplusplus)
30 
31 status_t rtm_create_pool(rtm_pool** out_pool, size_t total_size,
32 	const char* name = NULL);
33 
34 #else
35 
36 status_t rtm_create_pool(rtm_pool** out_pool, size_t total_size,
37 	const char* name);
38 
39 #endif
40 
41 status_t rtm_delete_pool(rtm_pool* pool);
42 
43 /* If NULL is passed for 'pool', the default pool is used if it has been */
44 /* created already. */
45 void* rtm_alloc(rtm_pool* pool, size_t size);
46 status_t rtm_free(void* data);
47 status_t rtm_realloc(void** data, size_t new_size);
48 status_t rtm_size_for(void* data);
49 status_t rtm_phys_size_for(void* data);
50 
51 /* Return the default pool, or NULL if it has not yet been initialized. */
52 rtm_pool* rtm_default_pool();
53 
54 #if defined(__cplusplus)
55 }
56 #endif
57 
58 #endif // _REALTIME_ALLOC_H
59 
60