📄 piece.h
字号:
#ifndef _RD_PIECE_H
#define _RD_PIECE_H
// piece data structure
typedef struct piece_ds {
void* startAddress;
unsigned long size;
}PIECE_DS, *PPIECE_DS;
/*************************************************************
Function: initPieceParameters
Description:
initialize the piece parameters
Input:
NONE
Output:
NONE
**************************************************************/
void initPieceParameters(void);
/*************************************************************
Function: initPLT
Description:
initialize the PLT
Input:
NONE
Output:
NONE
**************************************************************/
void initPLT(void);
/*************************************************************
Function: getPiece
Description:
get a piece from memory
Input:
wantSize
Output:
the pointer to the head of the piece
NULL if failed
**************************************************************/
//void *getPiece(void);
void *getPiece(unsigned long wantSize);
/*************************************************************
Function: addNewPieceToFBL
Description:
add a newly obtained piece to the free block list
Input:
piece - the new piece
size - the size of the piece
Output:
NONE
**************************************************************/
//void addNewPieceToFBL(void *piece);
void addNewPieceToFBL(void *piece, unsigned long size);
/*************************************************************
Function: freePiece
Description:
free a piece to memory
Input:
piece - the target piece
Output:
0 if succeeded
-1 if failed
**************************************************************/
int freePiece(void *piece);
/*************************************************************
Function: checkPieceFree
Description:
check if the target piece is completely free
Input:
piece - the target piece
Output:
1 if totally free
0 if not free
**************************************************************/
int checkPieceFree(void *piece);
/*************************************************************
Function: freeAllPieceNC
Description:
free all pieces without checking whether they are totally unused
Input:
index - freeing starts from this entry
Output:
NONE
**************************************************************/
void freeAllPieceNC(int index);
/*************************************************************
Function: freeUnusedPiece
Description:
free all unused pieces
Input:
index - freeing starts from this entry
Output:
number of pieces freed
**************************************************************/
int freeUnusedPiece(int index);
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -