Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

faux commit

  • Loading branch information...
commit 1c5dc7e07724f4388c66455aa42880c05705fffb 1 parent 99989a2
@bnoordhuis bnoordhuis authored
Showing with 24 additions and 3 deletions.
  1. +24 −3 src/uv.c
View
27 src/uv.c
@@ -20,6 +20,10 @@
#include <stdlib.h>
#include <string.h>
+static PyTypeObject tp_tcp;
+
+static PyObject *tp_tcp_new(PyTypeObject* type, PyObject *a, PyObject *b);
+
static PyObject *do_run(PyObject *a, PyObject *b);
static PyMethodDef methods[] = {
@@ -27,6 +31,23 @@ static PyMethodDef methods[] = {
{ NULL, NULL, 0, NULL }
};
+
+static PyObject *tp_tcp_new(PyTypeObject *type, PyObject *a, PyObject *b) {
+ uv_tcp_t *handle;
+
+ if ((handle = malloc(sizeof *handle)) == NULL)
+ goto out;
+
+ if (uv_tcp_init(handle)) {
+ free(handle);
+ goto out;
+ }
+
+out:
+ return 0;
+}
+
+
static PyObject *do_run(PyObject *a, PyObject *b) {
int r;
@@ -35,13 +56,13 @@ static PyObject *do_run(PyObject *a, PyObject *b) {
return PyInt_FromLong(r);
}
+
PyMODINIT_FUNC init(void) {
PyObject *module;
module = Py_InitModule3("uv", methods, "libuv bindings");
if (!module)
- goto out;
+ return;
-out:
- ;
+ tp_tcp.tp_new = tp_tcp_new;
}
Please sign in to comment.
Something went wrong with that request. Please try again.