On Tuesday 26 March 2002 17:38, kevin lyda wrote:
> not really. the idea would be this:
>> declare somefunc(taking some args):
> reservation = malloc_reserve(calc amount, RESERVE_CALLS, calc calls)
> if (reservation == 0):
> return failure
> end if
Ok, that makes the code neater. The parameters you're using are pretty hand-
wavey though. Surely you'd just pass an upper bound in bytes? Why would
it care how many calls you are going to make? And in terms of error detection
in turns multiple potential small leaks into one giant potential leak, which
is a big improvement but not ideal (probably as good as you'll get in C I
imagine).
> so the data is allocated a few milliseconds early. big deal. it's worth
In that example. But over an entire system you're bound to notice the effect.
> it for how much clearer the code would be. and yes, you can clean some
> of it up with goto's, but only some and it still means that very low
> level error checking has to pepper your code.
Yes, it'd be nice to find a solution that doesn't involve spaghetti code or
goto :)
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!