acme, sam: handle >1GB files correctly
TBR=rsc https://codereview.appspot.com/74060043
This commit is contained in:
parent
e78ed7a67b
commit
219cf22d68
4 changed files with 10 additions and 4 deletions
|
|
@ -69,7 +69,7 @@ struct Range
|
||||||
|
|
||||||
struct Block
|
struct Block
|
||||||
{
|
{
|
||||||
uint addr; /* disk address in bytes */
|
vlong addr; /* disk address in bytes */
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
uint n; /* number of used runes in block */
|
uint n; /* number of used runes in block */
|
||||||
|
|
@ -80,7 +80,7 @@ struct Block
|
||||||
struct Disk
|
struct Disk
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
uint addr; /* length of temp file */
|
vlong addr; /* length of temp file */
|
||||||
Block *free[Maxblock/Blockincr+1];
|
Block *free[Maxblock/Blockincr+1];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -82,6 +82,9 @@ disknewblock(Disk *d, uint n)
|
||||||
b = blist;
|
b = blist;
|
||||||
blist = b->u.next;
|
blist = b->u.next;
|
||||||
b->addr = d->addr;
|
b->addr = d->addr;
|
||||||
|
if(d->addr+size < d->addr){
|
||||||
|
error("temp file overflow");
|
||||||
|
}
|
||||||
d->addr += size;
|
d->addr += size;
|
||||||
}
|
}
|
||||||
b->u.n = n;
|
b->u.n = n;
|
||||||
|
|
|
||||||
|
|
@ -75,6 +75,9 @@ disknewblock(Disk *d, uint n)
|
||||||
b = blist;
|
b = blist;
|
||||||
blist = b->u.next;
|
blist = b->u.next;
|
||||||
b->addr = d->addr;
|
b->addr = d->addr;
|
||||||
|
if(d->addr+size < d->addr){
|
||||||
|
panic("temp file overflow");
|
||||||
|
}
|
||||||
d->addr += size;
|
d->addr += size;
|
||||||
}
|
}
|
||||||
b->u.n = n;
|
b->u.n = n;
|
||||||
|
|
|
||||||
|
|
@ -113,7 +113,7 @@ enum
|
||||||
|
|
||||||
struct Block
|
struct Block
|
||||||
{
|
{
|
||||||
uint addr; /* disk address in bytes */
|
vlong addr; /* disk address in bytes */
|
||||||
union {
|
union {
|
||||||
uint n; /* number of used runes in block */
|
uint n; /* number of used runes in block */
|
||||||
Block *next; /* pointer to next in free list */
|
Block *next; /* pointer to next in free list */
|
||||||
|
|
@ -123,7 +123,7 @@ struct Block
|
||||||
struct Disk
|
struct Disk
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
uint addr; /* length of temp file */
|
vlong addr; /* length of temp file */
|
||||||
Block *free[Maxblock/Blockincr+1];
|
Block *free[Maxblock/Blockincr+1];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue