ncloader  0.1
 모두 데이타 구조 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 매크로 그룹들 페이지들
The simplest memory allocator
+ The simplest memory allocator에 대한 협력 다이어그램:

데이타 구조

struct  chunk
 Chunk 자료구조 더 자세히 ...
 
struct  allocator
 Allocator handle 자료구조 더 자세히 ...
 

함수

struct allocatorallocator_init (unsigned int base, unsigned int size)
 Allocator 초기화를 한다. 더 자세히 ...
 
int allocator_fini (struct allocator *handle)
 Allocator 를 finalize 시킨다. 더 자세히 ...
 
void * allocator_alloc (struct allocator *handle, int size)
 메모리를 할당 한다. 더 자세히 ...
 
void allocator_free (struct allocator *handle, void *ptr)
 할당한 메모리를 해제한다. 더 자세히 ...
 
int allocator_chunk_size (void *ptr)
 할당된 메모리가 가진 크기를 얻는다. 더 자세히 ...
 

상세한 설명

함수 문서화

void * allocator_alloc ( struct allocator handle,
int  size 
)

메모리를 할당 한다.

매개변수
[in]handle
[in]size
반환값
void *
반환값
NULL
ptrAllocated address
주의
If the remained free size is more smaller than "chunk structure" size, Allocating a new chunk does not need make a new free node. It cannot be used anymore, in this case, Don't divide it into more smaller chunks.

We call this "INTERNAL FRAGMENTATION".

주의
Now, we can re-use the "tmp". Because we will not take outer loop anymore. So re-use the "tmp" for insertion sorting.
Reassign the "chunk" to handle->used.

+ 이 함수를 호출하는 함수들에 대한 그래프입니다.:

int allocator_chunk_size ( void *  ptr)

할당된 메모리가 가진 크기를 얻는다.

매개변수
[in]ptr
반환값
int
반환값
size

+ 이 함수를 호출하는 함수들에 대한 그래프입니다.:

int allocator_fini ( struct allocator handle)

Allocator 를 finalize 시킨다.

매개변수
[in]handle
반환값
int
반환값
0
void allocator_free ( struct allocator handle,
void *  ptr 
)

할당한 메모리를 해제한다.

매개변수
[in]handle
[in]ptr
반환값
void
반환값
none
주의
Disconnecting from the used list.
Insert a chunk to the free'd list.
tmp is merged with the chunk. and if the tmp is same with handle->freed, assign chunk to handle->freed.
Just expanding the size of tmp.
Insert a chunk to the free node list.

+ 이 함수를 호출하는 함수들에 대한 그래프입니다.:

struct allocator * allocator_init ( unsigned int  base,
unsigned int  size 
)

Allocator 초기화를 한다.

매개변수
[in]base
[in]size
반환값
struct allocator *
반환값
handle
NULL

+ 이 함수를 호출하는 함수들에 대한 그래프입니다.: