#include <elf.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <pthread.h>
#include "memorypool.h"
Go to the source code of this file.
|
|
static int | get_far_right_bit_index (uint64_t data) |
| get right bit index More...
|
|
static int | get_bit_digit_index_over_size (uint64_t size) |
| get minimum of x, which 2^x > input_value More...
|
|
|
MemoryPool | mpool_create (size_t max_size, size_t max_cnt, int is_multithread, void(*constructor)(void *this, void *parameter), void *constructor_parameter) |
|
void | mpool_delete (MemoryPool this, void(*destructor)(void *)) |
| free MemoryPool class More...
|
|
void * | mpool_get (MemoryPool this) |
| get memory from pool More...
|
|
void * | mpool_get_next_usedmem (MemoryPool this, void *ptr) |
| get used memory More...
|
|
size_t | mpool_get_usedcnt (MemoryPool this) |
| get used cnt More...
|
|
void | mpool_release (MemoryPool this, void *ptr) |
| release memory to pool More...
|
|
void | mpool_show (MemoryPool this) |
|
#define | MPOOL_LOCK(this) |
|
#define | MPOOL_UNLOCK pthread_cleanup_pop(1); |
|
typedef struct maloc_data_t | malloc_data_t |
|
typedef struct memorypool_t | memorypool_t |
|
static void | mpool_list_push (MemoryPool this, malloc_data_t *data) |
|
static void | mpool_list_pull (MemoryPool this, malloc_data_t *data) |
|
static void | mpool_list_head (MemoryPool this, malloc_data_t *data) |
|
static void * | mpool_get_memory (MemoryPool this) |
|
static void * | mpool_get_next_memory (MemoryPool this, void *ptr) |
|
static void | mpool_unuse_memory (MemoryPool this, void *ptr) |
|
static uint64_t | mpool_get_buffer_place (MemoryPool this, uint8_t *buffer_list, void *ptr) |
|
static int | mpool_is_not_ptr_in_buf (MemoryPool this, void *ptr) |
|
static void | pthread_mutex_unlock_ (void *arg) |
|
static void | pthread_mutex_lock_ (MemoryPool this) |
|
◆ MPOOL_LOCK
#define MPOOL_LOCK |
( |
|
this | ) |
|
Value:static void pthread_mutex_lock_(MemoryPool this)
static void pthread_mutex_unlock_(void *arg)
Definition at line 74 of file memorypool.c.
◆ MPOOL_UNLOCK
#define MPOOL_UNLOCK pthread_cleanup_pop(1); |
◆ malloc_data_t
◆ memorypool_t
◆ get_bit_digit_index_over_size()
static int get_bit_digit_index_over_size |
( |
uint64_t |
size | ) |
|
|
static |
get minimum of x, which 2^x > input_value
Definition at line 20 of file memorypool.c.
◆ get_far_right_bit_index()
static int get_far_right_bit_index |
( |
uint64_t |
data | ) |
|
|
static |
◆ mpool_create()
MemoryPool mpool_create |
( |
size_t |
max_size, |
|
|
size_t |
max_cnt, |
|
|
int |
is_multithread, |
|
|
void(*)(void *this, void *parameter) |
constructor, |
|
|
void * |
constructor_parameter |
|
) |
| |
◆ mpool_delete()
void mpool_delete |
( |
MemoryPool |
this, |
|
|
void(*)(void *) |
destructor |
|
) |
| |
free MemoryPool class
- Parameters
-
[in] | this | MemoryPool instance returned at mpool_malloc_new, |
[in] | destructor | if you want to finialize memory |
- Returns
- none
Definition at line 223 of file memorypool.c.
◆ mpool_get()
get memory from pool
- Parameters
-
[in] | this | MemoryPool instance returned at mpool_malloc_new, |
- Return values
-
!=NULL | allocated pointer |
NULL | max_size of allocated memory |
- Note
- If already get all allocated pointer, return NULL
Definition at line 236 of file memorypool.c.
◆ mpool_get_buffer_place()
static uint64_t mpool_get_buffer_place |
( |
MemoryPool |
this, |
|
|
uint8_t * |
buffer_list, |
|
|
void * |
ptr |
|
) |
| |
|
inlinestatic |
◆ mpool_get_memory()
◆ mpool_get_next_memory()
static void * mpool_get_next_memory |
( |
MemoryPool |
this, |
|
|
void * |
ptr |
|
) |
| |
|
inlinestatic |
◆ mpool_get_next_usedmem()
void* mpool_get_next_usedmem |
( |
MemoryPool |
this, |
|
|
void * |
ptr |
|
) |
| |
get used memory
- Parameters
-
[in] | this | MemoryPool instance return, |
[in] | ptr | used pointer |
- Return values
-
!=NULL | get next |
NULL | this pointer is end |
Definition at line 245 of file memorypool.c.
◆ mpool_get_usedcnt()
get used cnt
- Parameters
-
[in] | this | MemoryPool instance return, |
- Returns
- used count
Definition at line 257 of file memorypool.c.
◆ mpool_is_not_ptr_in_buf()
static int mpool_is_not_ptr_in_buf |
( |
MemoryPool |
this, |
|
|
void * |
ptr |
|
) |
| |
|
inlinestatic |
◆ mpool_list_head()
◆ mpool_list_pull()
◆ mpool_list_push()
◆ mpool_release()
void mpool_release |
( |
MemoryPool |
this, |
|
|
void * |
ptr |
|
) |
| |
release memory to pool
- Parameters
-
[in] | this | MemoryPool instance returned at mpool_malloc_new, |
[in] | ptr | allocated pointer which get from mpool_malloc |
- Returns
- none
- Note
- not initialize memory
Definition at line 266 of file memorypool.c.
◆ mpool_show()
◆ mpool_unuse_memory()
static void mpool_unuse_memory |
( |
MemoryPool |
this, |
|
|
void * |
ptr |
|
) |
| |
|
inlinestatic |
◆ pthread_mutex_lock_()
static void pthread_mutex_lock_ |
( |
MemoryPool |
this | ) |
|
|
inlinestatic |
◆ pthread_mutex_unlock_()
static void pthread_mutex_unlock_ |
( |
void * |
arg | ) |
|
|
inlinestatic |