Skip to content

Commit 3cb9b63

Browse files
committed
Fix opaque container on PyPy
1 parent e2ec340 commit 3cb9b63

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

av/opaque.pyx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
cimport libav as lib
2-
from libc.stdint cimport uint8_t
2+
from libc.stdint cimport intptr_t, uint8_t
33
from libc.string cimport memcpy
44

55

@@ -15,18 +15,18 @@ cdef class OpaqueContainer:
1515

1616
cdef lib.AVBufferRef *add(self, object v):
1717
# Use object's memory address as key
18-
cdef size_t key = id(v)
18+
cdef intptr_t key = id(v)
1919
self._objects[key] = v
2020

21-
cdef uint8_t *data = <uint8_t *>lib.av_malloc(sizeof(size_t))
21+
cdef uint8_t *data = <uint8_t *>lib.av_malloc(sizeof(intptr_t))
2222
if data == NULL:
2323
raise MemoryError("Failed to allocate memory for key")
2424

25-
memcpy(data, &key, sizeof(size_t))
25+
memcpy(data, &key, sizeof(intptr_t))
2626

2727
# Create the buffer with our free callback
2828
cdef lib.AVBufferRef *buffer_ref = lib.av_buffer_create(
29-
data, sizeof(size_t), key_free, NULL, 0
29+
data, sizeof(intptr_t), key_free, NULL, 0
3030
)
3131

3232
if buffer_ref == NULL:
@@ -35,11 +35,11 @@ cdef class OpaqueContainer:
3535
return buffer_ref
3636

3737
cdef object get(self, char *name):
38-
cdef size_t key = (<size_t *>name)[0]
38+
cdef intptr_t key = (<intptr_t *>name)[0]
3939
return self._objects.get(key)
4040

4141
cdef object pop(self, char *name):
42-
cdef size_t key = (<size_t *>name)[0]
42+
cdef intptr_t key = (<intptr_t *>name)[0]
4343
return self._objects.pop(key, None)
4444

4545

0 commit comments

Comments
 (0)