event-handling approach to errors

Mark Wittenberg mark at rtech.ARPA
Sat Mar 9 22:35:06 AEST 1985


> It would be really nice if you
> could intercept the out-of-bounds reference, determine that it was for
> one of the select list of "growable" arrays, and re-allocate the one
> involved to have more space.  
> 
> 			John Chambers

Of course this is essentially what the early "ed" editor did (does);
for all I know its derivatives do too:  when its array of line pointers
ran out of space it did a "free(); realloc()" to "grow" (copying only if needed)
the array.  I don't know how portable this use of realloc is though.
To be clear, ed doesn't "intercept the out-of-bounds reference"; it detects
when it's run out of space without generating an error.  I know it's not quite
the same thing, but this is the only common UN*X program that I know of which
does this "free & realloc" trick; anybody else know of others?
-- 

Mark Wittenberg
Relational Technology
zehntel!rtech!mark
ucbvax!mtxinu!rtech!mark



More information about the Comp.lang.c mailing list