Hi Igor: On 30 Jan 2013, at 09:53, Igor Stasenko wrote:
On 29 January 2013 23:56, Stefan Marr <smalltalk@stefan-marr.de> wrote:
Hi Igor:
On 29 Jan 2013, at 11:26, Igor Stasenko wrote:
| repo repoPath cb branches headHandle | repo := NBExternalHandle new. repoPath := NBExternalAddress fromString: '/Users/smarr/tmp/filetree'.
why not just pass the string?
I had the feeling (i.e., I had crashes, and was checking with GDB) that plain Smalltalk strings ala 'test' are not actually passed properly into the function. What is passed in is a reference to the begin of the string, but not a properly null terminated string.
Do I miss something?
Yes, to ease work with strings there is a special 'String' type it will automatically make a null-terminated copy of string on stack and pass it to function. So, you don't need to manually do 'NBExternalAddress fromString:' and then symmetrical #free, to free used memory, ( which your code snippet does not includes btw ;) ).
Right, I haven't worried about memory at all so far... libgit2 isn't entirely trivial in that regard. Ok, now that I saw NBExternalString, I added a type mapping to my list (char_ptr NBExternalString). How does it work for return types? You assume that you will have the responsibility to free the returned char* if I use NBExternalString as return type for functions that return char*? Thanks Stefan -- Stefan Marr Software Languages Lab Vrije Universiteit Brussel Pleinlaan 2 / B-1050 Brussels / Belgium http://soft.vub.ac.be/~smarr Phone: +32 2 629 2974 Fax: +32 2 629 3525