Tizen Native API
7.0
|
This provides a mechanism to defer actual freeing of memory data at some time in the future. The main free queue will be driven by the EFL main loop and ensure data is eventually freed.
For debugging and tuning you may set the following environment variables, applicable only to free queues of the default type:
EINA_FREEQ_BYPASS=1/0
Set this environment variable to 1 to immediately bypass the free queue and have all items submitted free with their free function immediately. Set it to 0 to force the free queue to work and delay freeing of items. Note that you can override this by setting count or mem max by eina_freeq_count_max_set() or eina_freeq_mem_max_set() which will disable bypass for that specific free queue. Once bypass is disabled it cannot be re-enabled.
EINA_FREEQ_FILL_MAX=N
This sets the maximum number of bytes to N an item in the free queue may be in size for the free queue to fill it with debugging values like 0x55 in every byte, to ensure you can see what memory has been freed or not when debugging in tools like gdb. Note that this value is actually one greater than the actual maximum, so if this is set to 100 a memory blob of 100 bytes will not be filled but one of 99 bytes in size will be.
EINA_FREEQ_TOTAL_MAX=N
This sets the maximum number of items allowed to N on a free queue by default before it starts emptying the free queue out to make room.
EINA_FREEQ_MEM_MAX=N
This sets the maximum total number of Kb (Kilobytes) of memory allowed on a free queue by default to N Kb worth of data.
EINA_FREEQ_FILL=N
This sets the byte value to write to every byte of an allocation that is added to the free queue when it is added to mark the data as invalid. The default value is 0x55 (85). Memory is only filled if the size of the allocation is less than the max that you can adjust with EINA_FREEQ_FILL_MAX.
EINA_FREEQ_FILL_FREED=N
Memory just before it is actually passed to the free function to be freed will be filled with this pattern value in every byte. The default value is 0x77 (119). Memory is only filled if the size of the allocation is less than the max that you can adjust with EINA_FREEQ_FILL_MAX.
- Since (EFL) :
- 1.19
Functions | |
Eina_FreeQ * | eina_freeq_new (Eina_FreeQ_Type type) |
Create a new free queue to defer freeing of data with. | |
void | eina_freeq_free (Eina_FreeQ *fq) |
Free a free queue and anything that is queued in it. | |
Eina_FreeQ_Type | eina_freeq_type_get (Eina_FreeQ *fq) |
Query the type of a free queue. | |
void | eina_freeq_count_max_set (Eina_FreeQ *fq, int count) |
Set the maximum number of free pointers this queue is allowed. | |
int | eina_freeq_count_max_get (Eina_FreeQ *fq) |
Get the maximum number of free pointers this queue is allowed. | |
size_t | eina_freeq_mem_max_get (Eina_FreeQ *fq) |
Get the maximum amount of memory allowed. | |
void | eina_freeq_clear (Eina_FreeQ *fq) |
Clear out all queued items to be freed by freeing them. | |
void | eina_freeq_reduce (Eina_FreeQ *fq, int count) |
Reduce the number of items in the free queue by up to count . | |
Eina_Bool | eina_freeq_ptr_pending (Eina_FreeQ *fq) |
Return if there are any items pending a free in the free queue. | |
static void | eina_freeq_ptr_main_add (void *ptr, void(*free_func)(void *ptr), size_t size) |
Add a pointer to the main free queue. | |
Typedefs | |
typedef struct _Eina_FreeQ | Eina_FreeQ |
typedef enum _Eina_FreeQ_Type | Eina_FreeQ_Type |
Type of free queues. | |
Defines | |
#define | EINA_FREEQ_FREE(ptr) eina_freeq_ptr_main_add(ptr, NULL, sizeof(*(ptr))) |
Convenience macro for well known structures and types. | |
#define | EINA_FREEQ_N_FREE(ptr, n) eina_freeq_ptr_main_add(ptr, NULL, sizeof(*(ptr)) * n) |
Convenience macro for well known structures and types. |
Define Documentation
#define EINA_FREEQ_FREE | ( | ptr | ) | eina_freeq_ptr_main_add(ptr, NULL, sizeof(*(ptr))) |
Convenience macro for well known structures and types.
- Parameters:
-
[in] ptr The pointer to free
This is the same as eina_freeq_ptr_main_add() but the free function is assumed to be the libc free() function, and size is provided by sizeof(*ptr), so it will not work on void pointers or will be inaccurate for pointers to arrays. For arrays please use EINA_FREEQ_ARRAY_FREE()
- Since (EFL) :
- 1.19
#define EINA_FREEQ_N_FREE | ( | ptr, | |
n | |||
) | eina_freeq_ptr_main_add(ptr, NULL, sizeof(*(ptr)) * n) |
Convenience macro for well known structures and types.
- Parameters:
-
[in] ptr The pointer to free
This is the same as eina_freeq_ptr_main_add() but the free function is assumed to be the libc free() function, and size is provided by sizeof(*ptr), so it will not work on void pointers. Total size is multiplied by the count n
so it should work well for arrays of types.
- Since (EFL) :
- 1.19
Typedef Documentation
A queue of pointers to free in the future. You may create custom free queues of your own to defer freeing, use the main free queue where the mainloop will free things as it iterates, or eina will free everything on shut down.
typedef enum _Eina_FreeQ_Type Eina_FreeQ_Type |
Type of free queues.
- Since (EFL) :
- 1.19
Enumeration Type Documentation
enum _Eina_FreeQ_Type |
Type of free queues.
- Since (EFL) :
- 1.19
- Enumerator:
Function Documentation
void eina_freeq_clear | ( | Eina_FreeQ * | fq | ) |
Clear out all queued items to be freed by freeing them.
- Parameters:
-
[in,out] fq The free queue to clear
This will free and thus remove all queued items from the free queue when this function is called. When it returns the free queue should be empty.
- Since (EFL) :
- 1.19
int eina_freeq_count_max_get | ( | Eina_FreeQ * | fq | ) |
Get the maximum number of free pointers this queue is allowed.
- Parameters:
-
[in] fq The free queue to query
- Returns:
- The maximum number of free items allowed or -1 for infinity
- Since (EFL) :
- 1.19
void eina_freeq_count_max_set | ( | Eina_FreeQ * | fq, |
int | count | ||
) |
Set the maximum number of free pointers this queue is allowed.
- Parameters:
-
[in,out] fq The free queue to alter [in] count The maximum number of items allowed, negative values mean no limit
This will alter the maximum number of pointers allowed in the given free queue. If more items are added to the free queue than are allowed, excess items will be freed to make room for the new items. If count is changed, then excess items may be cleaned out at the time this API is called.
- Note:
- Setting a maximum count on a postponed free queue leads to undefined behavior.
- Since (EFL) :
- 1.19
void eina_freeq_free | ( | Eina_FreeQ * | fq | ) |
Free a free queue and anything that is queued in it.
- Parameters:
-
[in,out] fq The free queue to free and clear.
- Since (EFL) :
- 1.19
size_t eina_freeq_mem_max_get | ( | Eina_FreeQ * | fq | ) |
Get the maximum amount of memory allowed.
- Parameters:
-
[in] fq The free queue to query
- Returns:
- The maximum amount of memory in bytes
- Since (EFL) :
- 1.19
Eina_FreeQ* eina_freeq_new | ( | Eina_FreeQ_Type | type | ) |
Create a new free queue to defer freeing of data with.
- Returns:
- A new free queue
- Since (EFL) :
- 1.19
static void eina_freeq_ptr_main_add | ( | void * | ptr, |
void(*)(void *ptr) | free_func, | ||
size_t | size | ||
) | [static] |
Add a pointer to the main free queue.
- Parameters:
-
[in] ptr The pointer to free [in] free_func The function used to free the pointer with [in] size The size of the data the pointer points to
This is the same as eina_freeq_ptr_add() but the main free queue is fetched by eina_freeq_main_get().
- Since (EFL) :
- 1.19
Return if there are any items pending a free in the free queue.
- Parameters:
-
[in] fq The free queue to query
- Returns:
- EINA_TRUE if there are items to free, EINA_FALSE otherwise
- Since (EFL) :
- 1.19
void eina_freeq_reduce | ( | Eina_FreeQ * | fq, |
int | count | ||
) |
Reduce the number of items in the free queue by up to count
.
- Parameters:
-
[in,out] fq The free queue to reduce in item count [in] count The number of items to try and free
This will attempt to free up to count
items from the given free queue and thus reduce the amount of memory it is holding on to. This function will return once it has removed count
items or there are no more items to remove from the queue.
- Since (EFL) :
- 1.19
Query the type of a free queue.
- Parameters:
-
[in] fq The free queue to inspect.
- Since (EFL) :
- 1.19