- Rename alloc/free to vfalloc/vffree to not conflict with other apps vfatlib links to.

svn path=/trunk/; revision=35144
This commit is contained in:
Aleksey Bragin 2008-08-06 12:03:34 +00:00
parent 77993cf0e3
commit 6735beea51
7 changed files with 47 additions and 47 deletions

View file

@ -130,7 +130,7 @@ loff_t alloc_rootdir_entry(DOS_FS *fs, DIR_ENT *de, const char *pattern)
DIR_ENT *root;
int next_free = 0, scan;
root = alloc(fs->root_entries*sizeof(DIR_ENT));
root = vfalloc(fs->root_entries*sizeof(DIR_ENT));
fs_read(fs->root_start,fs->root_entries*sizeof(DIR_ENT),root);
while (next_free < (int)fs->root_entries)
@ -151,7 +151,7 @@ loff_t alloc_rootdir_entry(DOS_FS *fs, DIR_ENT *de, const char *pattern)
if (scan == (int)fs->root_entries) break;
if (++curr_num >= 10000) die("Unable to create unique name");
}
free(root);
vffree(root);
}
++n_files;
return offset;

View file

@ -44,7 +44,7 @@ void pdie(char *msg,...)
}
void *alloc(int size)
void *vfalloc(int size)
{
void *ptr;
@ -61,7 +61,7 @@ void *alloc(int size)
return ptr;
}
void free(void *ptr)
void vffree(void *ptr)
{
RtlFreeHeap(RtlGetProcessHeap(), 0, ptr);
}
@ -70,10 +70,10 @@ void *qalloc(void **root,int size)
{
LINK *link;
link = alloc(sizeof(LINK));
link = vfalloc(sizeof(LINK));
link->next = *root;
*root = link;
return link->data = alloc(size);
return link->data = vfalloc(size);
}
@ -84,8 +84,8 @@ void qfree(void **root)
while (*root) {
this = (LINK *) *root;
*root = this->next;
free(this->data);
free(this);
vffree(this->data);
vffree(this);
}
}

View file

@ -17,8 +17,8 @@ void pdie(char *msg,...);
/* Like die, but appends an error message according to the state of errno. */
void *alloc(int size);
void free(void *ptr);
void *vfalloc(int size);
void vffree(void *ptr);
/* mallocs SIZE bytes and returns a pointer to the data. Terminates the program
if malloc fails. */

View file

@ -55,11 +55,11 @@ void read_fat(DOS_FS *fs)
if (eff_size % 512) {
eff_size += 512 - (eff_size % 512);
}
first = alloc(eff_size);
first = vfalloc(eff_size);
fs_read(fs->fat_start,eff_size,first);
use = first;
if (fs->nfats > 1) {
second = alloc(eff_size);
second = vfalloc(eff_size);
fs_read(fs->fat_start+fs->fat_size,eff_size,second);
}
else
@ -106,9 +106,9 @@ void read_fat(DOS_FS *fs)
i-2,fs->fat[i].value,fs->clusters+2-1);
set_fat(fs,i,-1);
}
free(first);
vffree(first);
if (second)
free(second);
vffree(second);
}

View file

@ -128,7 +128,7 @@ void file_add(char *path,FD_TYPE type)
die("Ambiguous name: \"%s\"",path);
else if (here && !strncmp(name,walk->name,MSDOS_NAME)) break;
if (!walk) {
walk = alloc(sizeof(FDSC));
walk = vfalloc(sizeof(FDSC));
strncpy(walk->name,name,MSDOS_NAME);
walk->type = here ? fdt_none : type;
walk->first = NULL;
@ -203,7 +203,7 @@ void file_modify(FDSC **curr,unsigned char *fixed)
die("Internal error: file_modify");
}
next = (*this)->next;
free(*this);
vffree(*this);
*this = next;
}
@ -218,7 +218,7 @@ static void report_unused(FDSC *this)
else if (this->type != fdt_none)
VfatPrint("Warning: did not %s file %s\n",this->type == fdt_drop ?
"drop" : "undelete",file_name((unsigned char*)this->name));
free(this);
vffree(this);
this = next;
}
}

View file

@ -86,14 +86,14 @@ void fs_read(loff_t pos,int size,void *data)
const loff_t seekpos_aligned = pos - (pos % 512); // TMN:
const size_t seek_delta = (size_t)(pos - seekpos_aligned); // TMN:
const size_t readsize = (size_t)(pos - seekpos_aligned) + readsize_aligned; // TMN:
char* tmpBuf = alloc(readsize_aligned); // TMN:
char* tmpBuf = vfalloc(readsize_aligned); // TMN:
if (llseek(fd,seekpos_aligned,0) != seekpos_aligned) pdie("Seek to %I64d",pos);
if ((got = read(fd,tmpBuf,readsize_aligned)) < 0) pdie("Read %d bytes at %I64d",size,pos);
assert(got >= size);
got = size;
assert(seek_delta + size <= readsize);
memcpy(data, tmpBuf+seek_delta, size);
free(tmpBuf);
vffree(tmpBuf);
#else // TMN:
if (llseek(fd,pos,0) != pos) pdie("Seek to %lld",pos);
if ((got = read(fd,data,size)) < 0) pdie("Read %d bytes at %lld",size,pos);
@ -119,15 +119,15 @@ int fs_test(loff_t pos,int size)
#if 1 // TMN
const size_t readsize_aligned = (size % 512) ? (size + (512 - (size % 512))) : size; // TMN:
const loff_t seekpos_aligned = pos - (pos % 512); // TMN:
scratch = alloc(readsize_aligned);
scratch = vfalloc(readsize_aligned);
if (llseek(fd,seekpos_aligned,0) != seekpos_aligned) pdie("Seek to %lld",pos);
okay = read(fd,scratch,readsize_aligned) == (int)readsize_aligned;
free(scratch);
vffree(scratch);
#else // TMN:
if (llseek(fd,pos,0) != pos) pdie("Seek to %lld",pos);
scratch = alloc(size);
scratch = vfalloc(size);
okay = read(fd,scratch,size) == size;
free(scratch);
vffree(scratch);
#endif // TMN:
return okay;
}
@ -148,7 +148,7 @@ void fs_write(loff_t pos,int size,void *data)
/* Aloc temp buffer if write is not aligned */
if (use_read)
scratch = alloc(readsize_aligned);
scratch = vfalloc(readsize_aligned);
else
scratch = data;
@ -167,16 +167,16 @@ void fs_write(loff_t pos,int size,void *data)
/* Write it back */
if ((did = write(fd,scratch,readsize_aligned)) == (int)readsize_aligned)
{
if (use_read) free(scratch);
if (use_read) vffree(scratch);
return;
}
if (did < 0) pdie("Write %d bytes at %I64d",size,pos);
die("Wrote %d bytes instead of %d at %I64d",did,size,pos);
}
new = alloc(sizeof(CHANGE));
new = vfalloc(sizeof(CHANGE));
new->pos = pos;
memcpy(new->data = alloc(new->size = size),data,size);
memcpy(new->data = vfalloc(new->size = size),data,size);
new->next = NULL;
if (last) last->next = new;
else changes = new;
@ -190,9 +190,9 @@ void fs_write(loff_t pos,int size,void *data)
if (did < 0) pdie("Write %d bytes at %lld",size,pos);
die("Wrote %d bytes instead of %d at %lld",did,size,pos);
}
new = alloc(sizeof(CHANGE));
new = vfalloc(sizeof(CHANGE));
new->pos = pos;
memcpy(new->data = alloc(new->size = size),data,size);
memcpy(new->data = vfalloc(new->size = size),data,size);
new->next = NULL;
if (last) last->next = new;
else changes = new;
@ -215,8 +215,8 @@ static void fs_flush(void)
fs_write(this->pos, this->size, this->data);
free(this->data);
free(this);
vffree(this->data);
vffree(this);
}
/* Restore values */
@ -233,8 +233,8 @@ int fs_close(int write)
if (write) fs_flush();
else while (changes) {
next = changes->next;
free(changes->data);
free(changes);
vffree(changes->data);
vffree(changes);
changes = next;
}
if (close(fd) < 0) pdie("closing file system");

View file

@ -81,7 +81,7 @@ static char *cnv_unicode( const unsigned char *uni, int maxlen, int use_q )
else
len += 4;
}
cp = out = use_q ? qalloc( &mem_queue, len+1 ) : alloc( len+1 );
cp = out = use_q ? qalloc( &mem_queue, len+1 ) : vfalloc( len+1 );
for( up = uni; (up-uni)/2 < maxlen && (up[0] || up[1]); up += 2 ) {
if (UNICODE_CONVERTABLE(up[0],up[1]))
@ -132,10 +132,10 @@ static void clear_lfn_slots( int start, int end )
void lfn_reset( void )
{
if (lfn_unicode)
free( lfn_unicode );
vffree( lfn_unicode );
lfn_unicode = NULL;
if (lfn_offsets)
free( lfn_offsets );
vffree( lfn_offsets );
lfn_offsets = NULL;
lfn_slot = -1;
}
@ -169,8 +169,8 @@ void lfn_add_slot( DIR_ENT *de, loff_t dir_offset )
char *part2 = CNV_PARTS_SO_FAR();
VfatPrint( " It could be that the LFN start bit is wrong here\n"
" if \"%s\" seems to match \"%s\".\n", part1, part2 );
free( part1 );
free( part2 );
vffree( part1 );
vffree( part2 );
can_clear = 1;
}
if (interactive) {
@ -197,8 +197,8 @@ void lfn_add_slot( DIR_ENT *de, loff_t dir_offset )
}
lfn_slot = lfn->id & LFN_ID_SLOTMASK;
lfn_checksum = lfn->alias_checksum;
lfn_unicode = alloc( (lfn_slot*CHARS_PER_LFN+1)*2 );
lfn_offsets = alloc( lfn_slot*sizeof(loff_t) );
lfn_unicode = vfalloc( (lfn_slot*CHARS_PER_LFN+1)*2 );
lfn_offsets = vfalloc( lfn_slot*sizeof(loff_t) );
lfn_parts = 0;
}
else if (lfn_slot == -1) {
@ -219,7 +219,7 @@ void lfn_add_slot( DIR_ENT *de, loff_t dir_offset )
switch( get_key( "123", "?" )) {
case '1':
if (!lfn_offsets)
lfn_offsets = alloc( sizeof(loff_t) );
lfn_offsets = vfalloc( sizeof(loff_t) );
lfn_offsets[0] = dir_offset;
clear_lfn_slots( 0, 0 );
lfn_reset();
@ -233,8 +233,8 @@ void lfn_add_slot( DIR_ENT *de, loff_t dir_offset )
sizeof(lfn->id), &lfn->id );
lfn_slot = lfn->id & LFN_ID_SLOTMASK;
lfn_checksum = lfn->alias_checksum;
lfn_unicode = alloc( (lfn_slot*CHARS_PER_LFN+1)*2 );
lfn_offsets = alloc( lfn_slot*sizeof(loff_t) );
lfn_unicode = vfalloc( (lfn_slot*CHARS_PER_LFN+1)*2 );
lfn_offsets = vfalloc( lfn_slot*sizeof(loff_t) );
lfn_parts = 0;
break;
}
@ -255,8 +255,8 @@ void lfn_add_slot( DIR_ENT *de, loff_t dir_offset )
char *part2 = CNV_PARTS_SO_FAR();
VfatPrint( " It could be that just the number is wrong\n"
" if \"%s\" seems to match \"%s\".\n", part1, part2 );
free( part1 );
free( part2 );
vffree( part1 );
vffree( part2 );
can_fix = 1;
}
if (interactive) {
@ -381,7 +381,7 @@ char *lfn_get( DIR_ENT *de )
VfatPrint( "Unfinished long file name \"%s\".\n"
" (Start may have been overwritten by %s)\n",
long_name, short_name );
free( long_name );
vffree( long_name );
if (interactive) {
VfatPrint( "1: Delete LFN\n2: Leave it as it is.\n"
"3: Fix numbering (truncates long name and attaches "
@ -421,7 +421,7 @@ char *lfn_get( DIR_ENT *de )
VfatPrint( "Wrong checksum for long file name \"%s\".\n"
" (Short name %s may have changed without updating the long name)\n",
long_name, short_name );
free( long_name );
vffree( long_name );
if (interactive) {
VfatPrint( "1: Delete LFN\n2: Leave it as it is.\n"
"3: Fix checksum (attaches to short name %s)\n",