Re: Loading database from string (C API)
Jan Wielemaker <[email protected]>
| Newsgroups | gmane.comp.ai.prolog.swi |
|---|---|
| Message-ID | <[email protected]> |
On 12/13/2013 11:19 AM, Edd Barrett wrote: > On Thu, Dec 12, 2013 at 09:38:29PM +0100, Jan Wielemaker wrote: >> Just a guess. Is the string properly allocated, such that it won't move >> or be overwritten or whatever if Prolog and or Python are going to >> do garbage collection or malloc() reuses the freed address, or ... > > Well, I tried strdup()ing the input string within the open_stream() > function. Sadly no joy. I wasn't happy, so I investigated a bit more. My advice was wrong. One should use Sopenmem() rather than Sopen_string(). The latter has a quite specific meaning in its interaction with read_term(). The attached program runs fine! Sorry for the confusion --- Jan -------------- next part -------------- A non-text attachment was scrubbed... Name: ct.c Type: text/x-csrc Size: 1063 bytes Desc: ct.c URL: <https://lists.iai.uni-bonn.de/pipermail/swi-prolog/attachments/20131213/b57f45be/attachment.bin>