1
0

heap_context_find_or_create.c 752 B

1234567891011121314151617181920212223242526272829
  1. #include "private.h"
  2. #include "context.h"
  3. /*--------------------------------------------------------- */
  4. const lub_heap_context_t *lub_heap_context_find_or_create(lub_heap_t * this,
  5. const stackframe_t *
  6. stack)
  7. {
  8. lub_heap_context_t *context;
  9. /*
  10. * look to see whether there is an
  11. * existing context for this allocation
  12. */
  13. context = lub_heap_context_find(stack);
  14. if (NULL == context) {
  15. lub_heap_leak_t *leak = lub_heap_leak_instance();
  16. context = lub_dblockpool_alloc(&leak->m_context_pool);
  17. lub_heap_leak_release(leak);
  18. if (NULL != context) {
  19. /* initialise the instance */
  20. lub_heap_context_init(context, this, stack);
  21. }
  22. }
  23. return context;
  24. }
  25. /*--------------------------------------------------------- */