blob: 3bb237dc4de389f5a9b04d5a744023b025eb10ee (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
#include "compound-file.h"
#include "emb-logging.h"
#include "helpers-binary.h"
#include <stdio.h>
#include <stdlib.h>
const unsigned int sizeOfFatEntry = sizeof(unsigned int);
bcf_file_fat* bcfFileFat_create(const unsigned int sectorSize)
{
bcf_file_fat* fat = (bcf_file_fat*)malloc(sizeof(bcf_file_fat));
if(!fat) { embLog_error("compound-file-fat.c bcfFileFat_create(), cannot allocate memory for fat\n"); } /* TODO: avoid crashing. null pointer will be accessed */
fat->numberOfEntriesInFatSector = sectorSize / sizeOfFatEntry;
fat->fatEntryCount = 0;
return fat;
}
void loadFatFromSector(bcf_file_fat* fat, EmbFile* file)
{
unsigned int i;
unsigned int currentNumberOfFatEntries = fat->fatEntryCount;
unsigned int newSize = currentNumberOfFatEntries + fat->numberOfEntriesInFatSector;
for(i = currentNumberOfFatEntries; i < newSize; ++i)
{
unsigned int fatEntry = binaryReadUInt32(file);
fat->fatEntries[i] = fatEntry;
}
fat->fatEntryCount = newSize;
}
void bcf_file_fat_free(bcf_file_fat* fat)
{
free(fat);
fat = 0;
}
/* kate: bom off; indent-mode cstyle; indent-width 4; replace-trailing-space-save on; */
|