mirror of
https://github.com/reactos/reactos.git
synced 2025-07-23 10:53:42 +00:00
[fullfat]
- Remove all malloc/free usage in the library and substitute them by user-provided FF_Malloc and FF_Free functions. - Cleanup fullfat.rbuild. svn path=/trunk/; revision=43221
This commit is contained in:
parent
f74bae6d05
commit
f1ee7979a1
5 changed files with 16 additions and 14 deletions
|
@ -52,5 +52,8 @@ void FF_putChar (FF_T_UINT8 *pBuffer, FF_T_UINT16 offset, FF_T_UINT8 Value);
|
|||
void FF_putShort (FF_T_UINT8 *pBuffer, FF_T_UINT16 offset, FF_T_UINT16 Value);
|
||||
void FF_putLong (FF_T_UINT8 *pBuffer, FF_T_UINT16 offset, FF_T_UINT32 Value);
|
||||
|
||||
void *FF_Malloc(FF_T_UINT32 allocSize);
|
||||
void FF_Free(void *pBuffer);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
2
reactos/lib/3rdparty/fullfat/ff_file.c
vendored
2
reactos/lib/3rdparty/fullfat/ff_file.c
vendored
|
@ -163,7 +163,7 @@ FF_FILE *FF_Open(FF_IOMAN *pIoman, const FF_T_INT8 *path, FF_T_UINT8 Mode, FF_ER
|
|||
}
|
||||
return (FF_FILE *)NULL;
|
||||
}
|
||||
pFile = malloc(sizeof(FF_FILE));
|
||||
pFile = FF_Malloc(sizeof(FF_FILE));
|
||||
if(!pFile) {
|
||||
if(pError) {
|
||||
*pError = FF_ERR_NOT_ENOUGH_MEMORY;
|
||||
|
|
2
reactos/lib/3rdparty/fullfat/ff_hash.c
vendored
2
reactos/lib/3rdparty/fullfat/ff_hash.c
vendored
|
@ -53,7 +53,7 @@ struct _FF_HASH_TABLE {
|
|||
*
|
||||
**/
|
||||
FF_HASH_TABLE FF_CreateHashTable() {
|
||||
FF_HASH_TABLE pHash = (FF_HASH_TABLE) malloc(sizeof(struct _FF_HASH_TABLE));
|
||||
FF_HASH_TABLE pHash = (FF_HASH_TABLE) FF_Malloc(sizeof(struct _FF_HASH_TABLE));
|
||||
|
||||
if(pHash) {
|
||||
FF_ClearHashTable(pHash);
|
||||
|
|
20
reactos/lib/3rdparty/fullfat/ff_ioman.c
vendored
20
reactos/lib/3rdparty/fullfat/ff_ioman.c
vendored
|
@ -89,7 +89,7 @@ FF_IOMAN *FF_CreateIOMAN(FF_T_UINT8 *pCacheMem, FF_T_UINT32 Size, FF_T_UINT16 Bl
|
|||
return NULL; // Memory Size not a multiple of BlkSize > 0
|
||||
}
|
||||
|
||||
pIoman = (FF_IOMAN *) malloc(sizeof(FF_IOMAN));
|
||||
pIoman = (FF_IOMAN *) FF_Malloc(sizeof(FF_IOMAN));
|
||||
|
||||
if(!pIoman) { // Ensure malloc() succeeded.
|
||||
if(pError) {
|
||||
|
@ -106,7 +106,7 @@ FF_IOMAN *FF_CreateIOMAN(FF_T_UINT8 *pCacheMem, FF_T_UINT32 Size, FF_T_UINT16 Bl
|
|||
pIoman->pPartition = NULL;
|
||||
pIoman->pSemaphore = NULL;
|
||||
|
||||
pIoman->pPartition = (FF_PARTITION *) malloc(sizeof(FF_PARTITION));
|
||||
pIoman->pPartition = (FF_PARTITION *) FF_Malloc(sizeof(FF_PARTITION));
|
||||
if(pIoman->pPartition) { // If succeeded, flag that allocation.
|
||||
pIoman->MemAllocation |= FF_IOMAN_ALLOC_PART;
|
||||
pIoman->pPartition->LastFreeCluster = 0;
|
||||
|
@ -127,7 +127,7 @@ FF_IOMAN *FF_CreateIOMAN(FF_T_UINT8 *pCacheMem, FF_T_UINT32 Size, FF_T_UINT16 Bl
|
|||
return NULL;
|
||||
}
|
||||
|
||||
pIoman->pBlkDevice = (FF_BLK_DEVICE *) malloc(sizeof(FF_BLK_DEVICE));
|
||||
pIoman->pBlkDevice = (FF_BLK_DEVICE *) FF_Malloc(sizeof(FF_BLK_DEVICE));
|
||||
if(pIoman->pBlkDevice) { // If succeeded, flag that allocation.
|
||||
pIoman->MemAllocation |= FF_IOMAN_ALLOC_BLKDEV;
|
||||
|
||||
|
@ -145,7 +145,7 @@ FF_IOMAN *FF_CreateIOMAN(FF_T_UINT8 *pCacheMem, FF_T_UINT32 Size, FF_T_UINT16 Bl
|
|||
if(pCacheMem) {
|
||||
pIoman->pCacheMem = pCacheMem;
|
||||
}else { // No-Cache buffer provided (malloc)
|
||||
pLong = (FF_T_UINT32 *) malloc(Size);
|
||||
pLong = (FF_T_UINT32 *) FF_Malloc(Size);
|
||||
pIoman->pCacheMem = (FF_T_UINT8 *) pLong;
|
||||
if(!pIoman->pCacheMem) {
|
||||
pIoman->MemAllocation |= FF_IOMAN_ALLOC_BUFFERS;
|
||||
|
@ -163,7 +163,7 @@ FF_IOMAN *FF_CreateIOMAN(FF_T_UINT8 *pCacheMem, FF_T_UINT32 Size, FF_T_UINT16 Bl
|
|||
/* Malloc() memory for buffer objects. (FullFAT never refers to a buffer directly
|
||||
but uses buffer objects instead. Allows us to provide thread safety.
|
||||
*/
|
||||
pIoman->pBuffers = (FF_BUFFER *) malloc(sizeof(FF_BUFFER) * pIoman->CacheSize);
|
||||
pIoman->pBuffers = (FF_BUFFER *) FF_Malloc(sizeof(FF_BUFFER) * pIoman->CacheSize);
|
||||
|
||||
if(pIoman->pBuffers) {
|
||||
pIoman->MemAllocation |= FF_IOMAN_ALLOC_BUFDESCR;
|
||||
|
@ -196,22 +196,22 @@ FF_ERROR FF_DestroyIOMAN(FF_IOMAN *pIoman) {
|
|||
|
||||
// Ensure pPartition pointer was allocated.
|
||||
if((pIoman->MemAllocation & FF_IOMAN_ALLOC_PART)) {
|
||||
free(pIoman->pPartition);
|
||||
FF_Free(pIoman->pPartition);
|
||||
}
|
||||
|
||||
// Ensure pBlkDevice pointer was allocated.
|
||||
if((pIoman->MemAllocation & FF_IOMAN_ALLOC_BLKDEV)) {
|
||||
free(pIoman->pBlkDevice);
|
||||
FF_Free(pIoman->pBlkDevice);
|
||||
}
|
||||
|
||||
// Ensure pBuffers pointer was allocated.
|
||||
if((pIoman->MemAllocation & FF_IOMAN_ALLOC_BUFDESCR)) {
|
||||
free(pIoman->pBuffers);
|
||||
FF_Free(pIoman->pBuffers);
|
||||
}
|
||||
|
||||
// Ensure pCacheMem pointer was allocated.
|
||||
if((pIoman->MemAllocation & FF_IOMAN_ALLOC_BUFFERS)) {
|
||||
free(pIoman->pCacheMem);
|
||||
FF_Free(pIoman->pCacheMem);
|
||||
}
|
||||
|
||||
// Destroy any Semaphore that was created.
|
||||
|
@ -220,7 +220,7 @@ FF_ERROR FF_DestroyIOMAN(FF_IOMAN *pIoman) {
|
|||
}
|
||||
|
||||
// Finally free the FF_IOMAN object.
|
||||
free(pIoman);
|
||||
FF_Free(pIoman);
|
||||
|
||||
return FF_ERR_NONE;
|
||||
}
|
||||
|
|
3
reactos/lib/3rdparty/fullfat/fullfat.rbuild
vendored
3
reactos/lib/3rdparty/fullfat/fullfat.rbuild
vendored
|
@ -1,8 +1,7 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd">
|
||||
<module name="fullfat" type="staticlibrary" allowwarnings="true">
|
||||
<module name="fullfat" type="staticlibrary">
|
||||
<include base="ReactOS">include/reactos/libs/fullfat</include>
|
||||
<define name="_DISABLE_TIDENTS" />
|
||||
<define name="__NTDRIVER__" />
|
||||
<define name="__NO_CTYPE_INLINES" />
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue