I have a program in python which is doing bit manipulations. Due to the big size of those binary dumps i'm using and to speed thing up i decided to do the manipulations in C. I use the ctypes extention with libraries to achieve this.
So what i have is:
IN PYTHON:
- a BitStream which i'm deviding in a list of Bytes
ex: [10101010,01010101,....]
- Then i encode thos bytes into number with the function
int("10101010",2) of python which gives me a number.
- then i put all those numbers in an list.
- [34,35,65]
- then with a loop i send those numbers 1 by 1 to my C function.
IN C:
- my C function gets the element 1 by 1 as they come and stores them into an globaly declared array of integers.
PROBLEM:
- The problem i have is that after a certain time or number of transactions, i get an Segment fault error
in my case to test if the numbers arrive to my C function i always send a counter back to python.
i send 4096 values to my C function after getting 2552 values back i get the Segment Fault error.
Here is my Code:
Python code:
Expand|Select|Wrap|Line Numbers
- for i in range(len(IntDump)):
- value = mylib.put_bin_into_array(IntDump[i])
- print value
Expand|Select|Wrap|Line Numbers
- int Array_Of_Numbers[4096][1];(global array)
- int Num_of_elements=0; (global variable)
- int put_bin_into_array(int number)
- {
- Array_Of_Numbers[Num_of_elements][0]=number;
- Num_of_elements++;
- return Num_of_elements;
- }
Thank You
Best Regards
Conter Thierry