Robin Popplestone writes:
> Needing to crunch a quarter of a million pixels in a hurry I have been
> reduced to writing 600 lines of C. How, I wondered to let C report its
> answers back to POP - these had to be line-segment records as well as
> an 512*512 array (something like the Ramsay and Barrett line-finder
> souped up) Now the array was no problem - POP knows how big it will
> be, and just gives C the array vector. Line segments, the number of
> which cannot be predicted, presented a harder problem. I didn't want
> to use a call-back to the POPLOG allocator, for various reasons. So I
> made POP hand C a large vector, which C then carves into segment
> records (using a segment-key handed in as an argument) and a left-over
> vector.
While supporting Robin's request for suitable .h files to make this
kind of programming safer, I am puzzled by the need for it here.
Why not pre-allocate all the line-segment records and stick them
into a vector (null-terminated)? This vector can then be passed to
C with impunity. It is admittedly slightly more space consuming
and likely to take more slightly time to preallocate. But this
seems like quite an acceptable cost to me.
Steve
|