Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

# distutils: depends = NTL/ZZ.h 

  

from cysignals.memory cimport sig_free 

from cysignals.signals cimport sig_off 

  

# Unset the signal handler and create a string from the buffer, 

# then free the memory in the buffer. 

cdef extern from "sage/libs/ntl/ntlwrap.h": 

void del_charstar(char*) 

  

cdef object string(char* s): 

""" 

Takes a char* allocated using malloc, and converts it to a Python 

string, then deletes the allocated memory. Also unsets the signal 

handler, so you *must* call sig_on() right before calling this! 

""" 

sig_off() 

# Makes a python string and deletes what is pointed to by s. 

t = str(s) 

sig_free(s) 

return t 

  

cdef object string_delete(char* s): 

""" 

Takes a char* allocated using C++ new, and converts it to a Python 

string, then deletes the allocated memory. Also unsets the signal 

handler, so you *must* call sig_on() right before calling this! 

""" 

sig_off() 

t = str(s) 

del_charstar(s) 

return t