Skip to content

Commit 72e220e

Browse files
author
Jake Moss
committed
sizeof(ulong) fix
1 parent c740fec commit 72e220e

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/flint/flintlib/flint.pxd

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ cdef extern from *:
5050
"""
5151

5252
cdef extern from "flint/flint.h":
53+
"""
54+
#define SIZEOF_ULONG sizeof(ulong)
55+
"""
56+
int SIZEOF_ULONG
5357
const char * FLINT_VERSION
5458
const int __FLINT_RELEASE
5559
const int FLINT_BITS

src/flint/types/nmod_mpoly.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ from flint.types.fmpz_vec cimport fmpz_vec
1414

1515
from flint.types.nmod cimport nmod
1616

17-
from flint.flintlib.flint cimport FLINT_BITS
17+
from flint.flintlib.flint cimport SIZEOF_ULONG
1818
from flint.flintlib.fmpz cimport fmpz_set
1919
from flint.flintlib.nmod_mpoly cimport (
2020
nmod_mpoly_add,
@@ -696,7 +696,7 @@ cdef class nmod_mpoly(flint_mpoly):
696696
cdef:
697697
# Using sizeof(ulong) here breaks on 64 windows machines because of the `ctypedef unsigned long ulong` in
698698
# flintlib/flint.pxd. Cython will inline this definition and then allocate the wrong amount of memory.
699-
ulong *vals = <ulong *>libc.stdlib.malloc(nargs * (FLINT_BITS // 4))
699+
ulong *vals = <ulong *>libc.stdlib.malloc(nargs * SIZEOF_ULONG)
700700
ulong res
701701
if vals is NULL:
702702
raise MemoryError("malloc returned a null pointer") # pragma: no cover

0 commit comments

Comments
 (0)