summaryrefslogtreecommitdiff
path: root/portato/mq.pyx
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.net>2009-08-15 11:46:13 +0200
committerRené 'Necoro' Neumann <necoro@necoro.net>2009-08-15 11:46:13 +0200
commit44d410d007e88d794e35e322082bec3ec69d5fa7 (patch)
tree61d43446b31b234e89b4cda50c341de326d0b176 /portato/mq.pyx
parent327be30ad41bd0ea9c6757b7d527ab9d5baee2ef (diff)
downloadportato-44d410d007e88d794e35e322082bec3ec69d5fa7.tar.gz
portato-44d410d007e88d794e35e322082bec3ec69d5fa7.tar.bz2
portato-44d410d007e88d794e35e322082bec3ec69d5fa7.zip
Finish mq module
Diffstat (limited to '')
-rw-r--r--portato/mq.pyx12
1 files changed, 6 insertions, 6 deletions
diff --git a/portato/mq.pyx b/portato/mq.pyx
index a5d0745..e9ce464 100644
--- a/portato/mq.pyx
+++ b/portato/mq.pyx
@@ -84,7 +84,7 @@ cdef class MessageQueue (object):
if size >= MAX_MESSAGE_SIZE:
raise ValueError("Message must be smaller than %d", MAX_MESSAGE_SIZE)
- msg = <msg_data*>malloc(sizeof(msg_data) + size)
+ msg = <msg_data*>PyMem_Malloc(sizeof(msg_data) + size)
if msg is NULL:
raise MemoryError("Out of memory")
@@ -93,7 +93,7 @@ cdef class MessageQueue (object):
msg.mtype = type
with nogil:
- ret = msgsnd(self.msgid, &msg, size, 0)
+ ret = msgsnd(self.msgid, msg, size, 0)
try:
if ret == -1:
@@ -106,14 +106,14 @@ cdef class MessageQueue (object):
else:
raise OSError(errno, strerror(errno))
finally:
- free(msg)
+ PyMem_Free(msg)
def receive (self):
cdef msg_data * msg
cdef int ret
cdef object retTuple
- msg = <msg_data*>malloc(sizeof(msg_data) + MAX_MESSAGE_SIZE)
+ msg = <msg_data*>PyMem_Malloc(sizeof(msg_data) + MAX_MESSAGE_SIZE)
if msg is NULL:
raise MemoryError("Out of memory")
@@ -134,9 +134,9 @@ cdef class MessageQueue (object):
else:
raise OSError(errno, strerror(errno))
- retTuple = (msg.mtext, msg.mtype)
+ retTuple = (PyString_FromStringAndSize(msg.mtext, ret), msg.mtype)
finally:
- free(msg)
+ PyMem_Free(msg)
return retTuple