01:08
speeder39_ has joined #pypy
01:19
lritter has quit [Remote host closed the connection]
01:42
jcea has quit [Remote host closed the connection]
01:43
jcea has joined #pypy
02:00
bbot2 has joined #pypy
03:15
jcea has quit [Quit: jcea]
04:43
forgottenone has joined #pypy
05:06
irclogs_io_bot has quit [Remote host closed the connection]
05:11
irclogs_io_bot has joined #pypy
05:35
_whitelogger has joined #pypy
05:58
speeder39_ has quit [Quit: Connection closed for inactivity]
06:53
dddddd has quit [Remote host closed the connection]
07:18
arigato has joined #pypy
07:30
arigato has quit [Ping timeout: 245 seconds]
07:45
arigato has joined #pypy
08:42
arigato has quit [Ping timeout: 268 seconds]
08:54
arigato has joined #pypy
09:38
_whitelogger has joined #pypy
09:46
Zaab1t has joined #pypy
10:34
smvv has joined #pypy
12:10
jcea has joined #pypy
13:05
arigato has quit [Remote host closed the connection]
13:06
lritter has joined #pypy
13:50
dddddd has joined #pypy
15:12
thnee has quit [Quit: WeeChat 1.9.1]
15:21
<
rjarry >
I have a C lib function that returns an allocated struct pointer
15:21
<
rjarry >
how can I control how this pointer is freed when the python refcount reaches 0 ?
15:21
<
rjarry >
I mean, is there a way to tell what function should be called to free the pointer
15:25
<
simpson >
rjarry: Yeah, there's a custom allocator hook. Lemme find the docs.
15:26
<
rjarry >
I had looked at this, but it does not fit with what I need
15:26
<
rjarry >
hi simpson :)
15:27
<
rjarry >
the object is not allocated with ffi.new()
15:28
<
rjarry >
here's an example, I have a C function: struct my_complex_struct *get_data(const void *params);
15:28
<
rjarry >
and I also have
15:28
<
rjarry >
void free_complex_struct(struct my_complex_struct *);
15:29
<
rjarry >
from python, if I call: s = lib.get_data(xxx)
15:29
<
rjarry >
how can I make sure that lib.free_complex_struct(s) is called when the refcount reaches 0 ?
15:30
<
rjarry >
(or maybe I misunderstood something)
15:36
<
rjarry >
oh awesome, thanks simpson
15:37
<
ronan >
rjarry: or you can just write a class with a __del__, or (better) use a context manager
15:38
<
rjarry >
ronan, can you give me an example ?
15:43
<
ronan >
this is a class that does both: uses
__del__ and can be used with 'with:'
15:44
<
ronan >
but the basic idea is just to call lib.get_data() from __init__() and lib.free_complex_struct() from __del__()
15:45
<
ronan >
(which is equivalent to what ffi.gc() does)
15:52
__pv has quit [Remote host closed the connection]
16:33
smvv has quit [Quit: Connection closed for inactivity]
17:50
dddddd has quit [Remote host closed the connection]
18:22
__pv has joined #pypy
18:23
themsay has joined #pypy
18:28
themsay has quit [Ping timeout: 252 seconds]
19:15
Zaab1t has quit [Quit: bye bye friends]
22:34
jamesaxl has quit [Quit: WeeChat 2.2]
23:37
lritter has quit [Quit: Leaving]
23:47
jacob22__ has quit [Remote host closed the connection]