summaryrefslogtreecommitdiff
path: root/portato
diff options
context:
space:
mode:
Diffstat (limited to 'portato')
-rw-r--r--portato/mq.pxd3
-rw-r--r--portato/mq.pyx12
2 files changed, 8 insertions, 7 deletions
diff --git a/portato/mq.pxd b/portato/mq.pxd
index ab5cfbe..be7631b 100644
--- a/portato/mq.pxd
+++ b/portato/mq.pxd
@@ -10,7 +10,8 @@
#
# Written by René 'Necoro' Neumann <necoro@necoro.net>
-from stdlib cimport *
+from python_string cimport *
+from python_mem cimport *
cdef extern from "errno.h":
int errno
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
r>2007-08-05i18n support and german translationsnecoro19-87/+1391 2007-08-04added an uncaught exception dialognecoro2-2/+1 2007-08-04added an uncaught exception dialognecoro4-3/+93 2007-08-04bugfixesnecoro3-5/+20 2007-08-01Removed "(GTK)" from desktop filenecoro1-1/+1 2007-07-30updatesnecoro1-1/+1 2007-07-30updatesnecoro2-21/+64 2007-07-28some more pause emerge itemsnecoro5-276/+423 2007-07-27changed design / added linknecoro3-66/+154 2007-07-26changed design / added linknecoro2-34/+27 2007-07-25changed design / added linknecoro5-86/+188 2007-07-24made the resume_loop-plugin change titles toonecoro5-7/+22 2007-07-21added logviewersnecoro7-215/+429 2007-07-21updated howtonecoro1-14/+24 2007-07-20new Plugin Schemenecoro1-5/+4 2007-07-20new Plugin Schemenecoro1-1/+1 2007-07-20new Plugin Schemenecoro9-162/+214 2007-07-13fixesnecoro4-27/+37 2007-07-13new fancier log outputnecoro14-127/+116 2007-07-11added SIGSTOP/SIGCONT support; SIGTERM now works ;)necoro8-208/+275 2007-07-09bug in shutdown pluginnecoro2-5/+12 2007-07-09added resume_loop pluginnecoro1-1/+1 2007-07-09added resume_loop pluginnecoro10-22/+162 2007-07-07some more documentationnecoro6-4/+108 2007-07-07Some documentation worknecoro7-18/+129