View Single Post
Old 2012-10-26, 20:39   #8
Batalov
 
Batalov's Avatar
 
"Serge"
Mar 2008
Phi(4,2^7658614+1)/2

22·32·7·37 Posts
Default

Quote:
Originally Posted by burrobert View Post
Thanks for your suggestions Dubslow. I firstly tried running the code on a larger integer but this produced the same error. Your second suggestion however was correct. I used the msieve_obj_new() function to create and initialise the msieve_obj and this removed the problem. It is interesting though that there was no problem on my Macbook Pro both when I compiled and ran the program in xcode and when I did it from the command line. I guess as a general principle though it is better to use a provided initialiser. Thanks for your help.
The demo.c code is deliberately outside of the library, so that all the API was clear; it can be read and cut-and-pasted. You cannot just call the core methods (from any library, not just libmsieve) without the proper initialization.

Also, generally it is not a robust idea to manually set up some variables when the constructor (in this case, msieve_obj_new()) exists. Over the course of time, the library can be later updated, methods refactored, etc, and the new constructor will take care of that, but the raw code will fail. That is all of course unless the role of the raw code is for one day/one test only and then to be deleted.

Last fiddled with by Batalov on 2012-10-26 at 20:47
Batalov is offline   Reply With Quote