On 5 May 2014 21:45, John Ralls <[email protected]> wrote:
> ...
> It's because dbi_initialize_r() is the only function that needs to write to 
> the dbi_instance; everything else just reads it. That makes managing the 
> memory the application's job and allows other approaches than allocating it 
> on the heap, including the static allocation that Moritz chose to use in his 
> implementation. The "_r" suffix to the function name is analogous to 
> gmtime_r, localtime_r, etc. which take a struct tm* from the caller instead 
> of using a static in the library code. Making the rest of the functions use 
> pass-by-copy saves a multi-threaded program from having to synchronize their 
> calls, though using const dbi_inst* instead would have allowed for cleaner 
> semantics when they choose to put it on the heap.

That makes sense, though the fact that two users separately got the
interface wrong does make one wonder whether it is ideal.  It also
does not help that it is actually defined as void* or something
similar so the compiler was not able to identify that the original
call to initialize was wrong (I think, I have not looked at it in
detail).

Cheers

Colin

_______________________________________________
gnucash-devel mailing list
[email protected]
https://lists.gnucash.org/mailman/listinfo/gnucash-devel

Reply via email to