File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -174,3 +174,26 @@ void umf_ba_linear_destroy(umf_ba_linear_pool_t *pool) {
174
174
util_mutex_destroy_not_free (& pool -> metadata .lock );
175
175
ba_os_free (pool , pool -> metadata .pool_size );
176
176
}
177
+
178
+ int umf_ba_linear_pool_contains_pointer (umf_ba_linear_pool_t * pool , void * ptr ) {
179
+ util_mutex_lock (& pool -> metadata .lock );
180
+ char * cptr = (char * )ptr ;
181
+ if (cptr >= pool -> data &&
182
+ cptr < ((char * )(pool )) + pool -> metadata .pool_size ) {
183
+ util_mutex_unlock (& pool -> metadata .lock );
184
+ return 1 ;
185
+ }
186
+
187
+ umf_ba_next_linear_pool_t * next_pool = pool -> next_pool ;
188
+ while (next_pool ) {
189
+ if (cptr >= next_pool -> data &&
190
+ cptr < ((char * )(next_pool )) + next_pool -> pool_size ) {
191
+ util_mutex_unlock (& pool -> metadata .lock );
192
+ return 1 ;
193
+ }
194
+ next_pool = next_pool -> next_pool ;
195
+ }
196
+
197
+ util_mutex_unlock (& pool -> metadata .lock );
198
+ return 0 ;
199
+ }
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ typedef struct umf_ba_linear_pool umf_ba_linear_pool_t;
26
26
umf_ba_linear_pool_t * umf_ba_linear_create (size_t pool_size );
27
27
void * umf_ba_linear_alloc (umf_ba_linear_pool_t * pool , size_t size );
28
28
void umf_ba_linear_destroy (umf_ba_linear_pool_t * pool );
29
+ int umf_ba_linear_pool_contains_pointer (umf_ba_linear_pool_t * pool , void * ptr );
29
30
30
31
#ifdef __cplusplus
31
32
}
You can’t perform that action at this time.
0 commit comments