POV-Ray : Newsgroups : povray.off-topic : This is great : Re: This is great Server Time
5 Sep 2024 19:28:18 EDT (-0400)
  Re: This is great  
From: Darren New
Date: 24 Aug 2009 12:23:12
Message: <4a92be70$1@news.povray.org>
Invisible wrote:
> The way I read it, they had a structure with two integers and a void 
> pointer.

It says "each event was passed around with two integer arguments and a void 
pointer in case you needed extra parameters."

I guess you could read that as an event being an object or structure. I read 
it as an event being a function call with three arguments. I see now that it 
is pretty ambiguous.

Either way, the right answer was to add the extra field if they needed it. 
It's hard to understand how that would be difficult, with the compiler 
catching the mistakes for you. Harder to be sure if it's an allocated 
structure passed around rather than function arguments, for sure.

> Then again, we're talking about a large, complex codebase. Maybe there's 
> something relevant they forgot to mention or something...

If it's passed around as arguments, you first have to track down all the 
functions that are "event" functions and add the new argument, then pass 
that argument from caller event functions to callee event functions if 
events can call other events. The compiler will help here. (Indeed, you can 
just add the extra argument, and compile, and fix the 
wrong-number-of-arguments error and compile, and etc, working your way up 
the call chain.) Falls apart if you're doing something to queue events for 
later or some such, and the function doing the queuing fails to queue the 
new argument that the function dequeuing needs. That's a bit harder to track 
down.

If it's a structure, you have to make sure you allocate and free the right 
amount of memory, which could certainly be a problem if you're silly enough 
to hard-code the size of the structure (or assumptions about the size) 
anywhere. For example, if you have a big queue of events, and you need 1000 
of them to fit in 8K of memory, and they're 8 bytes each, adding another 2 
bytes to each is going to push you over the limit.

Impossible to say without more info.

-- 
   Darren New, San Diego CA, USA (PST)
   Understanding the structure of the universe
    via religion is like understanding the
     structure of computers via Tron.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.