Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(28579)

Unified Diff: Modules/_uuidmodule.c

Issue 20519: ctypes.create_string_buffer creates reference cycles
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Lib/uuid.py ('k') | setup.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Modules/_uuidmodule.c Wed Oct 28 13:29:38 2015 +0000
@@ -0,0 +1,45 @@
+#include "Python.h"
+#include <uuid/uuid.h>
+
+static PyObject *
+_uuid_generate_random(void)
+{
+ uuid_t out;
+ uuid_generate_random(out);
+ return PyBytes_FromStringAndSize((const char *) out, sizeof(out));
+}
+
+static PyObject *
+_uuid_generate_time(void)
+{
+ uuid_t out;
+ uuid_generate_time(out);
+ return PyBytes_FromStringAndSize((const char *) out, sizeof(out));
+}
+
+
+static PyMethodDef uuid_methods[] = {
+ {"generate_random", (PyCFunction)_uuid_generate_random, METH_NOARGS, NULL},
+ {"generate_time", (PyCFunction)_uuid_generate_time, METH_NOARGS, NULL},
+ {NULL, NULL, 0, NULL} /* sentinel */
+};
+
+
+static struct PyModuleDef uuidmodule = {
+ PyModuleDef_HEAD_INIT,
+ "_uuid",
+ NULL,
+ -1,
+ uuid_methods,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
+PyMODINIT_FUNC
+PyInit__uuid(void)
+{
+ assert(sizeof(uuid_t) == 16);
+ return PyModule_Create(&uuidmodule);
+}
« no previous file with comments | « Lib/uuid.py ('k') | setup.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+