Skip to content

Commit

Permalink
core/alloc: add function to retrieve current allocator
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronmdjones committed Jan 20, 2019
1 parent fd6bf51 commit 14aeded
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
11 changes: 11 additions & 0 deletions src/libmowgli/core/alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,17 @@ mowgli_free(void *ptr)
tag->allocator->deallocate(tag);
}

/*
* \brief Gets the mowgli.allocation_policy used by the allocation primitives.
*
* \return The mowgli_allocation_policy_t object currently in use.
*/
mowgli_allocation_policy_t * MOWGLI_FATTR_RETURNS_NONNULL
mowgli_allocator_get_policy(void)
{
return _mowgli_allocator;
}

/*
* \brief Sets the mowgli.allocation_policy used by the allocation primitives.
*
Expand Down
4 changes: 4 additions & 0 deletions src/libmowgli/core/alloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,8 @@ extern char *mowgli_strndup(const char *in, size_t size)

extern void mowgli_free(void *ptr);

extern mowgli_allocation_policy_t *mowgli_allocator_get_policy(void) MOWGLI_FATTR_RETURNS_NONNULL;
extern void mowgli_allocator_set_policy(mowgli_allocation_policy_t *policy);
extern void mowgli_allocator_set_policy_by_name(const char *name);

#endif /* MOWGLI_SRC_LIBMOWGLI_CORE_ALLOC_H_INCLUDE_GUARD */
4 changes: 0 additions & 4 deletions src/libmowgli/core/allocation_policy.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,4 @@ typedef struct
mowgli_allocation_policy_t *mowgli_allocation_policy_create(const char *name, mowgli_allocation_func_t allocator, mowgli_deallocation_func_t deallocator);
mowgli_allocation_policy_t *mowgli_allocation_policy_lookup(const char *name);

/* for mowgli_alloc, et. al */
void mowgli_allocator_set_policy(mowgli_allocation_policy_t *policy);
void mowgli_allocator_set_policy_by_name(const char *name);

#endif /* MOWGLI_SRC_LIBMOWGLI_CORE_ALLOCATION_POLICY_H_INCLUDE_GUARD */

0 comments on commit 14aeded

Please sign in to comment.