mirror of
https://github.com/reactos/reactos.git
synced 2025-04-22 13:10:39 +00:00
- 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:
parent
77993cf0e3
commit
6735beea51
7 changed files with 47 additions and 47 deletions
|
@ -130,7 +130,7 @@ loff_t alloc_rootdir_entry(DOS_FS *fs, DIR_ENT *de, const char *pattern)
|
||||||
DIR_ENT *root;
|
DIR_ENT *root;
|
||||||
int next_free = 0, scan;
|
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);
|
fs_read(fs->root_start,fs->root_entries*sizeof(DIR_ENT),root);
|
||||||
|
|
||||||
while (next_free < (int)fs->root_entries)
|
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 (scan == (int)fs->root_entries) break;
|
||||||
if (++curr_num >= 10000) die("Unable to create unique name");
|
if (++curr_num >= 10000) die("Unable to create unique name");
|
||||||
}
|
}
|
||||||
free(root);
|
vffree(root);
|
||||||
}
|
}
|
||||||
++n_files;
|
++n_files;
|
||||||
return offset;
|
return offset;
|
||||||
|
|
|
@ -44,7 +44,7 @@ void pdie(char *msg,...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void *alloc(int size)
|
void *vfalloc(int size)
|
||||||
{
|
{
|
||||||
void *ptr;
|
void *ptr;
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ void *alloc(int size)
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void free(void *ptr)
|
void vffree(void *ptr)
|
||||||
{
|
{
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, ptr);
|
RtlFreeHeap(RtlGetProcessHeap(), 0, ptr);
|
||||||
}
|
}
|
||||||
|
@ -70,10 +70,10 @@ void *qalloc(void **root,int size)
|
||||||
{
|
{
|
||||||
LINK *link;
|
LINK *link;
|
||||||
|
|
||||||
link = alloc(sizeof(LINK));
|
link = vfalloc(sizeof(LINK));
|
||||||
link->next = *root;
|
link->next = *root;
|
||||||
*root = link;
|
*root = link;
|
||||||
return link->data = alloc(size);
|
return link->data = vfalloc(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -84,8 +84,8 @@ void qfree(void **root)
|
||||||
while (*root) {
|
while (*root) {
|
||||||
this = (LINK *) *root;
|
this = (LINK *) *root;
|
||||||
*root = this->next;
|
*root = this->next;
|
||||||
free(this->data);
|
vffree(this->data);
|
||||||
free(this);
|
vffree(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,8 @@ void pdie(char *msg,...);
|
||||||
|
|
||||||
/* Like die, but appends an error message according to the state of errno. */
|
/* Like die, but appends an error message according to the state of errno. */
|
||||||
|
|
||||||
void *alloc(int size);
|
void *vfalloc(int size);
|
||||||
void free(void *ptr);
|
void vffree(void *ptr);
|
||||||
/* mallocs SIZE bytes and returns a pointer to the data. Terminates the program
|
/* mallocs SIZE bytes and returns a pointer to the data. Terminates the program
|
||||||
if malloc fails. */
|
if malloc fails. */
|
||||||
|
|
||||||
|
|
|
@ -55,11 +55,11 @@ void read_fat(DOS_FS *fs)
|
||||||
if (eff_size % 512) {
|
if (eff_size % 512) {
|
||||||
eff_size += 512 - (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);
|
fs_read(fs->fat_start,eff_size,first);
|
||||||
use = first;
|
use = first;
|
||||||
if (fs->nfats > 1) {
|
if (fs->nfats > 1) {
|
||||||
second = alloc(eff_size);
|
second = vfalloc(eff_size);
|
||||||
fs_read(fs->fat_start+fs->fat_size,eff_size,second);
|
fs_read(fs->fat_start+fs->fat_size,eff_size,second);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -106,9 +106,9 @@ void read_fat(DOS_FS *fs)
|
||||||
i-2,fs->fat[i].value,fs->clusters+2-1);
|
i-2,fs->fat[i].value,fs->clusters+2-1);
|
||||||
set_fat(fs,i,-1);
|
set_fat(fs,i,-1);
|
||||||
}
|
}
|
||||||
free(first);
|
vffree(first);
|
||||||
if (second)
|
if (second)
|
||||||
free(second);
|
vffree(second);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -128,7 +128,7 @@ void file_add(char *path,FD_TYPE type)
|
||||||
die("Ambiguous name: \"%s\"",path);
|
die("Ambiguous name: \"%s\"",path);
|
||||||
else if (here && !strncmp(name,walk->name,MSDOS_NAME)) break;
|
else if (here && !strncmp(name,walk->name,MSDOS_NAME)) break;
|
||||||
if (!walk) {
|
if (!walk) {
|
||||||
walk = alloc(sizeof(FDSC));
|
walk = vfalloc(sizeof(FDSC));
|
||||||
strncpy(walk->name,name,MSDOS_NAME);
|
strncpy(walk->name,name,MSDOS_NAME);
|
||||||
walk->type = here ? fdt_none : type;
|
walk->type = here ? fdt_none : type;
|
||||||
walk->first = NULL;
|
walk->first = NULL;
|
||||||
|
@ -203,7 +203,7 @@ void file_modify(FDSC **curr,unsigned char *fixed)
|
||||||
die("Internal error: file_modify");
|
die("Internal error: file_modify");
|
||||||
}
|
}
|
||||||
next = (*this)->next;
|
next = (*this)->next;
|
||||||
free(*this);
|
vffree(*this);
|
||||||
*this = next;
|
*this = next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,7 +218,7 @@ static void report_unused(FDSC *this)
|
||||||
else if (this->type != fdt_none)
|
else if (this->type != fdt_none)
|
||||||
VfatPrint("Warning: did not %s file %s\n",this->type == fdt_drop ?
|
VfatPrint("Warning: did not %s file %s\n",this->type == fdt_drop ?
|
||||||
"drop" : "undelete",file_name((unsigned char*)this->name));
|
"drop" : "undelete",file_name((unsigned char*)this->name));
|
||||||
free(this);
|
vffree(this);
|
||||||
this = next;
|
this = next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,14 +86,14 @@ void fs_read(loff_t pos,int size,void *data)
|
||||||
const loff_t seekpos_aligned = pos - (pos % 512); // TMN:
|
const loff_t seekpos_aligned = pos - (pos % 512); // TMN:
|
||||||
const size_t seek_delta = (size_t)(pos - seekpos_aligned); // TMN:
|
const size_t seek_delta = (size_t)(pos - seekpos_aligned); // TMN:
|
||||||
const size_t readsize = (size_t)(pos - seekpos_aligned) + readsize_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 (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);
|
if ((got = read(fd,tmpBuf,readsize_aligned)) < 0) pdie("Read %d bytes at %I64d",size,pos);
|
||||||
assert(got >= size);
|
assert(got >= size);
|
||||||
got = size;
|
got = size;
|
||||||
assert(seek_delta + size <= readsize);
|
assert(seek_delta + size <= readsize);
|
||||||
memcpy(data, tmpBuf+seek_delta, size);
|
memcpy(data, tmpBuf+seek_delta, size);
|
||||||
free(tmpBuf);
|
vffree(tmpBuf);
|
||||||
#else // TMN:
|
#else // TMN:
|
||||||
if (llseek(fd,pos,0) != pos) pdie("Seek to %lld",pos);
|
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);
|
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
|
#if 1 // TMN
|
||||||
const size_t readsize_aligned = (size % 512) ? (size + (512 - (size % 512))) : size; // TMN:
|
const size_t readsize_aligned = (size % 512) ? (size + (512 - (size % 512))) : size; // TMN:
|
||||||
const loff_t seekpos_aligned = pos - (pos % 512); // 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);
|
if (llseek(fd,seekpos_aligned,0) != seekpos_aligned) pdie("Seek to %lld",pos);
|
||||||
okay = read(fd,scratch,readsize_aligned) == (int)readsize_aligned;
|
okay = read(fd,scratch,readsize_aligned) == (int)readsize_aligned;
|
||||||
free(scratch);
|
vffree(scratch);
|
||||||
#else // TMN:
|
#else // TMN:
|
||||||
if (llseek(fd,pos,0) != pos) pdie("Seek to %lld",pos);
|
if (llseek(fd,pos,0) != pos) pdie("Seek to %lld",pos);
|
||||||
scratch = alloc(size);
|
scratch = vfalloc(size);
|
||||||
okay = read(fd,scratch,size) == size;
|
okay = read(fd,scratch,size) == size;
|
||||||
free(scratch);
|
vffree(scratch);
|
||||||
#endif // TMN:
|
#endif // TMN:
|
||||||
return okay;
|
return okay;
|
||||||
}
|
}
|
||||||
|
@ -148,7 +148,7 @@ void fs_write(loff_t pos,int size,void *data)
|
||||||
|
|
||||||
/* Aloc temp buffer if write is not aligned */
|
/* Aloc temp buffer if write is not aligned */
|
||||||
if (use_read)
|
if (use_read)
|
||||||
scratch = alloc(readsize_aligned);
|
scratch = vfalloc(readsize_aligned);
|
||||||
else
|
else
|
||||||
scratch = data;
|
scratch = data;
|
||||||
|
|
||||||
|
@ -167,16 +167,16 @@ void fs_write(loff_t pos,int size,void *data)
|
||||||
/* Write it back */
|
/* Write it back */
|
||||||
if ((did = write(fd,scratch,readsize_aligned)) == (int)readsize_aligned)
|
if ((did = write(fd,scratch,readsize_aligned)) == (int)readsize_aligned)
|
||||||
{
|
{
|
||||||
if (use_read) free(scratch);
|
if (use_read) vffree(scratch);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (did < 0) pdie("Write %d bytes at %I64d",size,pos);
|
if (did < 0) pdie("Write %d bytes at %I64d",size,pos);
|
||||||
die("Wrote %d bytes instead of %d at %I64d",did,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;
|
new->pos = pos;
|
||||||
memcpy(new->data = alloc(new->size = size),data,size);
|
memcpy(new->data = vfalloc(new->size = size),data,size);
|
||||||
new->next = NULL;
|
new->next = NULL;
|
||||||
if (last) last->next = new;
|
if (last) last->next = new;
|
||||||
else changes = 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);
|
if (did < 0) pdie("Write %d bytes at %lld",size,pos);
|
||||||
die("Wrote %d bytes instead of %d at %lld",did,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;
|
new->pos = pos;
|
||||||
memcpy(new->data = alloc(new->size = size),data,size);
|
memcpy(new->data = vfalloc(new->size = size),data,size);
|
||||||
new->next = NULL;
|
new->next = NULL;
|
||||||
if (last) last->next = new;
|
if (last) last->next = new;
|
||||||
else changes = new;
|
else changes = new;
|
||||||
|
@ -215,8 +215,8 @@ static void fs_flush(void)
|
||||||
|
|
||||||
fs_write(this->pos, this->size, this->data);
|
fs_write(this->pos, this->size, this->data);
|
||||||
|
|
||||||
free(this->data);
|
vffree(this->data);
|
||||||
free(this);
|
vffree(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Restore values */
|
/* Restore values */
|
||||||
|
@ -233,8 +233,8 @@ int fs_close(int write)
|
||||||
if (write) fs_flush();
|
if (write) fs_flush();
|
||||||
else while (changes) {
|
else while (changes) {
|
||||||
next = changes->next;
|
next = changes->next;
|
||||||
free(changes->data);
|
vffree(changes->data);
|
||||||
free(changes);
|
vffree(changes);
|
||||||
changes = next;
|
changes = next;
|
||||||
}
|
}
|
||||||
if (close(fd) < 0) pdie("closing file system");
|
if (close(fd) < 0) pdie("closing file system");
|
||||||
|
|
|
@ -81,7 +81,7 @@ static char *cnv_unicode( const unsigned char *uni, int maxlen, int use_q )
|
||||||
else
|
else
|
||||||
len += 4;
|
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 ) {
|
for( up = uni; (up-uni)/2 < maxlen && (up[0] || up[1]); up += 2 ) {
|
||||||
if (UNICODE_CONVERTABLE(up[0],up[1]))
|
if (UNICODE_CONVERTABLE(up[0],up[1]))
|
||||||
|
@ -132,10 +132,10 @@ static void clear_lfn_slots( int start, int end )
|
||||||
void lfn_reset( void )
|
void lfn_reset( void )
|
||||||
{
|
{
|
||||||
if (lfn_unicode)
|
if (lfn_unicode)
|
||||||
free( lfn_unicode );
|
vffree( lfn_unicode );
|
||||||
lfn_unicode = NULL;
|
lfn_unicode = NULL;
|
||||||
if (lfn_offsets)
|
if (lfn_offsets)
|
||||||
free( lfn_offsets );
|
vffree( lfn_offsets );
|
||||||
lfn_offsets = NULL;
|
lfn_offsets = NULL;
|
||||||
lfn_slot = -1;
|
lfn_slot = -1;
|
||||||
}
|
}
|
||||||
|
@ -169,8 +169,8 @@ void lfn_add_slot( DIR_ENT *de, loff_t dir_offset )
|
||||||
char *part2 = CNV_PARTS_SO_FAR();
|
char *part2 = CNV_PARTS_SO_FAR();
|
||||||
VfatPrint( " It could be that the LFN start bit is wrong here\n"
|
VfatPrint( " It could be that the LFN start bit is wrong here\n"
|
||||||
" if \"%s\" seems to match \"%s\".\n", part1, part2 );
|
" if \"%s\" seems to match \"%s\".\n", part1, part2 );
|
||||||
free( part1 );
|
vffree( part1 );
|
||||||
free( part2 );
|
vffree( part2 );
|
||||||
can_clear = 1;
|
can_clear = 1;
|
||||||
}
|
}
|
||||||
if (interactive) {
|
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_slot = lfn->id & LFN_ID_SLOTMASK;
|
||||||
lfn_checksum = lfn->alias_checksum;
|
lfn_checksum = lfn->alias_checksum;
|
||||||
lfn_unicode = alloc( (lfn_slot*CHARS_PER_LFN+1)*2 );
|
lfn_unicode = vfalloc( (lfn_slot*CHARS_PER_LFN+1)*2 );
|
||||||
lfn_offsets = alloc( lfn_slot*sizeof(loff_t) );
|
lfn_offsets = vfalloc( lfn_slot*sizeof(loff_t) );
|
||||||
lfn_parts = 0;
|
lfn_parts = 0;
|
||||||
}
|
}
|
||||||
else if (lfn_slot == -1) {
|
else if (lfn_slot == -1) {
|
||||||
|
@ -219,7 +219,7 @@ void lfn_add_slot( DIR_ENT *de, loff_t dir_offset )
|
||||||
switch( get_key( "123", "?" )) {
|
switch( get_key( "123", "?" )) {
|
||||||
case '1':
|
case '1':
|
||||||
if (!lfn_offsets)
|
if (!lfn_offsets)
|
||||||
lfn_offsets = alloc( sizeof(loff_t) );
|
lfn_offsets = vfalloc( sizeof(loff_t) );
|
||||||
lfn_offsets[0] = dir_offset;
|
lfn_offsets[0] = dir_offset;
|
||||||
clear_lfn_slots( 0, 0 );
|
clear_lfn_slots( 0, 0 );
|
||||||
lfn_reset();
|
lfn_reset();
|
||||||
|
@ -233,8 +233,8 @@ void lfn_add_slot( DIR_ENT *de, loff_t dir_offset )
|
||||||
sizeof(lfn->id), &lfn->id );
|
sizeof(lfn->id), &lfn->id );
|
||||||
lfn_slot = lfn->id & LFN_ID_SLOTMASK;
|
lfn_slot = lfn->id & LFN_ID_SLOTMASK;
|
||||||
lfn_checksum = lfn->alias_checksum;
|
lfn_checksum = lfn->alias_checksum;
|
||||||
lfn_unicode = alloc( (lfn_slot*CHARS_PER_LFN+1)*2 );
|
lfn_unicode = vfalloc( (lfn_slot*CHARS_PER_LFN+1)*2 );
|
||||||
lfn_offsets = alloc( lfn_slot*sizeof(loff_t) );
|
lfn_offsets = vfalloc( lfn_slot*sizeof(loff_t) );
|
||||||
lfn_parts = 0;
|
lfn_parts = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -255,8 +255,8 @@ void lfn_add_slot( DIR_ENT *de, loff_t dir_offset )
|
||||||
char *part2 = CNV_PARTS_SO_FAR();
|
char *part2 = CNV_PARTS_SO_FAR();
|
||||||
VfatPrint( " It could be that just the number is wrong\n"
|
VfatPrint( " It could be that just the number is wrong\n"
|
||||||
" if \"%s\" seems to match \"%s\".\n", part1, part2 );
|
" if \"%s\" seems to match \"%s\".\n", part1, part2 );
|
||||||
free( part1 );
|
vffree( part1 );
|
||||||
free( part2 );
|
vffree( part2 );
|
||||||
can_fix = 1;
|
can_fix = 1;
|
||||||
}
|
}
|
||||||
if (interactive) {
|
if (interactive) {
|
||||||
|
@ -381,7 +381,7 @@ char *lfn_get( DIR_ENT *de )
|
||||||
VfatPrint( "Unfinished long file name \"%s\".\n"
|
VfatPrint( "Unfinished long file name \"%s\".\n"
|
||||||
" (Start may have been overwritten by %s)\n",
|
" (Start may have been overwritten by %s)\n",
|
||||||
long_name, short_name );
|
long_name, short_name );
|
||||||
free( long_name );
|
vffree( long_name );
|
||||||
if (interactive) {
|
if (interactive) {
|
||||||
VfatPrint( "1: Delete LFN\n2: Leave it as it is.\n"
|
VfatPrint( "1: Delete LFN\n2: Leave it as it is.\n"
|
||||||
"3: Fix numbering (truncates long name and attaches "
|
"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"
|
VfatPrint( "Wrong checksum for long file name \"%s\".\n"
|
||||||
" (Short name %s may have changed without updating the long name)\n",
|
" (Short name %s may have changed without updating the long name)\n",
|
||||||
long_name, short_name );
|
long_name, short_name );
|
||||||
free( long_name );
|
vffree( long_name );
|
||||||
if (interactive) {
|
if (interactive) {
|
||||||
VfatPrint( "1: Delete LFN\n2: Leave it as it is.\n"
|
VfatPrint( "1: Delete LFN\n2: Leave it as it is.\n"
|
||||||
"3: Fix checksum (attaches to short name %s)\n",
|
"3: Fix checksum (attaches to short name %s)\n",
|
||||||
|
|
Loading…
Reference in a new issue