pyodide/packages/python-sat/patches/force_malloc.patch

55 lines
1.2 KiB
Diff

diff --git a/cardenc/pycard.cc b/cardenc/pycard.cc
index 4ae27fe..5941d0a 100644
--- a/cardenc/pycard.cc
+++ b/cardenc/pycard.cc
@@ -11,6 +11,7 @@
#include <setjmp.h>
#include <signal.h>
#include <stdio.h>
+#include <stdlib.h>
#include <Python.h>
#include "card.hh"
@@ -122,8 +123,14 @@ static struct PyModuleDef module_def = {
NULL, /* m_free */
};
+static volatile int *_dummy_malloc;
+
PyMODINIT_FUNC PyInit_pycard(void)
{
+ _dummy_malloc = (int *)malloc(sizeof(int));
+ *_dummy_malloc = 1;
+ free((void *)_dummy_malloc);
+
PyObject *m = PyModule_Create(&module_def);
if (m == NULL)
diff --git a/solvers/pysolvers.cc b/solvers/pysolvers.cc
index 7066cb4..6b4d7de 100644
--- a/solvers/pysolvers.cc
+++ b/solvers/pysolvers.cc
@@ -15,6 +15,7 @@
#include <setjmp.h>
#include <signal.h>
#include <stdio.h>
+#include <stdlib.h>
#include <vector>
#ifdef WITH_CADICAL
@@ -493,8 +494,14 @@ static struct PyModuleDef module_def = {
NULL, /* m_free */
};
+static volatile int *_dummy_malloc;
+
PyMODINIT_FUNC PyInit_pysolvers(void)
{
+ _dummy_malloc = (int *)malloc(sizeof(int));
+ *_dummy_malloc = 1;
+ free((void *)_dummy_malloc);
+
PyObject *m = PyModule_Create(&module_def);
if (m == NULL)