#include "globals.h"
#include "pool.h"
#include <stdint.h>
#include <libiberty/splay-tree.h>
#include <stdarg.h>
Go to the source code of this file.
|
| struct | MEMoid_st |
| | The struct that stores the memptr for the object. More...
|
| |
| struct | addr2memoid_key |
| | The structure used in spaly_tree which used for getting MEMoid from the memory address. More...
|
| |
◆ __FILENAME__
| #define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__) |
◆ KEY_FIRST
◆ KEY_LAST
◆ memalloc
The user API for requesting allocation of object.
Example
- Parameters
-
| size | the size of memory that needs to be allocated. |
| which_ram | (optional): the RAM in which the user wants to place the object |
- Returns
MEMoidKey that the user needs to typecast into LIB_TOID.
- Note
- The API interface and functionality is almost exactly similar to that of
malloc().
- See also
- _memalloc() __memalloc()
Definition at line 79 of file malloc.h.
◆ memfree
| #define memfree |
( |
|
o | ) |
_memfree((o).oidkey) |
The user API to free the memory space allocated.
Example
- Parameters
-
| LIB_TOID | object: the object that was return by memalloc() during allocation. |
- Note
- The API interface and functionality is almost exactly similar to that of
free().
- See also
- _memfree() nvm_free()
Definition at line 109 of file malloc.h.
◆ NUMARGS
| #define NUMARGS |
( |
|
... | ) |
(sizeof((int[]){0, ##__VA_ARGS__})/sizeof(int)-1) |
◆ addr2memoid_key
The structure used in spaly_tree which used for getting MEMoid from the memory address.
◆ MEMoid
The struct that stores the memptr for the object.
◆ MEMoidKey
The key of the HashTable that contains <MEMoidKey, MEMoid>.
This is the library level representation of pointer to the object.
Definition at line 49 of file malloc.h.
◆ splay_comp
| Enumerator |
|---|
| cmp_node | |
| cmp_addr | |
Definition at line 110 of file malloc.h.
◆ _key_get_first()
◆ _key_get_last()
◆ _memalloc()
| MEMoidKey _memalloc |
( |
size_t |
size, |
|
|
const char * |
file, |
|
|
const char * |
func, |
|
|
const int |
line, |
|
|
int |
num_args, |
|
|
|
... |
|
) |
| |
Allocates the memory requested and returns a MEMoidKey.
- Parameters
-
| size | the size of the object that needs to be allocated. |
| file | the file where the requested object is defined. |
| func | the function where the requested object is defined. |
| line | the line number where the requested object is defined. |
| which_ram | (optional): the RAM in which the allocation must happen. |
- Returns
- The
MEMoidkey object after allocation is completed.
- See also
- __memalloc() memalloc()
- Attention
- This function is responsible for checking if the requested object is present in NVRAM from the previous run (to ensure
crash consistency).
-
It has to add the created objects into
object_maintainance table, type_table and splay_tree.
Definition at line 202 of file malloc.c.
◆ _memfree()
The fucntion to free the allocated memory location.
- Parameters
-
| oidkey | the MEMoidKey of the object whose memory needs to be freed. |
- Returns
- Nothing.
- Note
- This function doesn't call nvm_free() or
free() by itself, instead it enques the deletion task for the deletion thread to take care of it.
Definition at line 358 of file malloc.c.
◆ allot_first_free_offset()
| MEMoid allot_first_free_offset |
( |
size_t |
size | ) |
|
Allocates the first free memory chunk of the given size.
- Parameters
-
| size | the size of memory that needs to be allocated. |
- Returns
MEMoid object.
- Attention
- This function is responsible to create a new
pool iff any of the previous pools are insufficient for the asked size.
- See also
- allot_first_free_offset_pool()
Definition at line 104 of file malloc.c.
◆ allot_first_free_offset_pool()
Allocates first free memory chunk of the given size in the given pool specified by pool_id.
- Parameters
-
| pool_id | the ID of the pool where the allocation needs to be made. |
| size | the size of memory that needs to be allocated. |
- Returns
- The
offset of the memory chuck allocated. This offset is from the first address of the pool.
- Note
- This is an internal function. It is not exposed to other files.
- See also
- allot_first_free_offset()
Definition at line 48 of file malloc.c.
◆ get_memobj_direct()
| void* get_memobj_direct |
( |
MEMoid |
oid | ) |
|
The function to return the actual memptr for a given MEMoid object.
- Parameters
-
- Returns
- The memory address represented by
oid.
Definition at line 316 of file malloc.c.
◆ init_splay()
◆ addr2MemOID_read
| splay_tree addr2MemOID_read |
◆ addr2MemOID_write
| splay_tree addr2MemOID_write |
◆ MEMOID_NULL
| const MEMoid MEMOID_NULL = { 0, 0, 0 } |
|
static |
Just a dummy obj.
Definition at line 52 of file malloc.h.