cfbolz changed the topic of #pypy to: PyPy, the flexible snake (IRC logs: https://botbot.me/freenode/pypy/ ) | use cffi for calling C | mac OS and Fedora are not Windows
adamholmberg has quit [Remote host closed the connection]
<mssun>
cfbolz, simpson: "mssun: what mssun wants is possible. the pypy interpreter can be compiled together with an rpython program, and then you can just call the rpython methods of eg the objspace to run python code. the main downside is that the compilation times are a bit terrrible". Sorry for the late reply. I was trying to use libffi to call libpypy from rpython code. The problem is that many symbols/functions are shared.
cjwelborn has quit [Write error: Connection reset by peer]
forgottenone has quit [Quit: Konversation terminated!]
themsay has joined #pypy
moei has joined #pypy
marky1991 has joined #pypy
marky1991 has quit [Remote host closed the connection]
marky1991 has joined #pypy
themsay has quit [Ping timeout: 252 seconds]
oberstet has joined #pypy
oberstet has quit [Remote host closed the connection]
lritter has joined #pypy
thinkwell has joined #pypy
thinkwell has left #pypy [#pypy]
marky1991 has quit [Ping timeout: 268 seconds]
Sigyn has quit [Quit: People always have such a hard time believing that robots could do bad things.]
Sigyn has joined #pypy
adamholmberg has joined #pypy
antocuni has joined #pypy
inhahe has quit [Read error: Connection reset by peer]
inhahe has joined #pypy
Rhy0lite has joined #pypy
dustinm- has quit [Quit: Leaving]
dustinm has joined #pypy
Zaab1t has joined #pypy
dddddd has joined #pypy
marky1991 has joined #pypy
marky1991 has quit [Remote host closed the connection]
marky1991 has joined #pypy
marky1991 has quit [Remote host closed the connection]
marky1991 has joined #pypy
marky1991 has quit [Ping timeout: 246 seconds]
rjarry has joined #pypy
<rjarry>
hi all
<rjarry>
I am looking for some insight on cffi
<rjarry>
I have a C library that exports a function: int write_mem(char **strp, ....);
<rjarry>
which allocates a string and sets the allocated buffer address to the given pointer
marky1991 has joined #pypy
<rjarry>
the caller is responsible for freeing the pointer
<rjarry>
how do I call this from python code ?
<rjarry>
I tried a lot of things, but none work
<tos9>
rjarry: what did you try
<rjarry>
buf = ffi.new('char *')
<rjarry>
buf_p = ffi.new('char **', buf)
<rjarry>
lib.write_mem(buf_p, ...)
<rjarry>
lib.write_mem(ffi.addressof(buf), ...)
<rjarry>
oh, it looks like this works:
<rjarry>
buf = ffi.new('char **')
<rjarry>
lib.write_mem(buf, ...)
<rjarry>
and then, access buf[0]
<rjarry>
but will the allocated memory be free automatically ?
<simpson>
rjarry: Yes.
<rjarry>
awesome, thanks
forgottenone has joined #pypy
<antocuni>
rjarry: make sure to keep "buf" alive
<antocuni>
else the memory is freed as soon as buf.__del__ is called (which happens immediately when refcount==0 on CPython, and eventually when the GC runs on PyPy)
ronan__ has joined #pypy
ronan__ has quit [Ping timeout: 250 seconds]
marky1991 has quit [Ping timeout: 272 seconds]
antocuni has quit [Ping timeout: 244 seconds]
marky1991 has joined #pypy
ronan__ has joined #pypy
ronan__ has quit [Client Quit]
ronan__ has joined #pypy
ronan__ has quit [Client Quit]
ronan__ has joined #pypy
ronan__ has quit [Read error: Connection reset by peer]
ronan__ has joined #pypy
Zaab1t has quit [Quit: bye bye friends]
ronan__ has quit [Read error: Connection reset by peer]
ronan__ has joined #pypy
ronan__ has quit [Client Quit]
moei has quit [Read error: Connection reset by peer]
moei has joined #pypy
Zaab1t has joined #pypy
adamholmberg has quit [Remote host closed the connection]
adamholmberg has joined #pypy
Rhy0lite has quit [Quit: Leaving]
jacob22__ has quit [Ping timeout: 244 seconds]
marky1991 has quit [Read error: Connection reset by peer]
marky1991 has joined #pypy
Zaab1t has quit [Quit: bye bye friends]
kenaan has quit [Ping timeout: 252 seconds]
jacob22__ has joined #pypy
danieljabailey has quit [Read error: Connection reset by peer]
moei has quit [Quit: Leaving...]
untitaker_ has quit [Ping timeout: 252 seconds]
untitaker_ has joined #pypy
marky1991 has quit [Remote host closed the connection]