hi, I'm writing a program a kind of calculator that should work with very big numbers (thousand of digits). So, numbers are rappresented by a struct that contains a pointer to integer, e 2 int for dimension of the array e number of digits.
the pointer is than used for the malloc of the array...
my 2 problems are:
1)some time, when I use my exp function I get the error:
*** glibc detected *** ./a.out: free(): invalid size: 0x0975a328 ***
======= Backtrace: =========
/lib/tls/i686/cmov/libc.so.6[0xb7e8b604]
/lib/tls/i686/cmov/libc.so.6[0xb7e8eabc]
/lib/tls/i686/cmov/libc.so.6(__lib c_malloc+0x95)[0xb7e8f9c5]
./a.out[0x804a8ab]
./a.out[0x804bb52]
./a.out[0x804ba3d]
./a.out[0x804ba3d]
./a.out[0x804ba3d]
./a.out[0x804ba3d]
./a.out[0x804ba3d]
./a.out[0x804ba3d]
./a.out[0x8049e32]
./a.out[0x8048892]
/lib/tls/i686/cmov/libc.so.6(__lib c_start_main+0x e5)[0xb7e32775]
./a.out[0x8048401]
and other stuff... can It be becouse it is a recursive function?
the second and biggest problem is that when the number becomes too large (something like 1000 digits) I get a segmentation fault... there are strange problems with arrays of this dimension?
the code is very big but you can find it at:
ps: I've deleted the free() functions... It caused too many errors...
thanks for you help, and sorry for my eng...
the pointer is than used for the malloc of the array...
my 2 problems are:
1)some time, when I use my exp function I get the error:
*** glibc detected *** ./a.out: free(): invalid size: 0x0975a328 ***
======= Backtrace: =========
/lib/tls/i686/cmov/libc.so.6[0xb7e8b604]
/lib/tls/i686/cmov/libc.so.6[0xb7e8eabc]
/lib/tls/i686/cmov/libc.so.6(__lib c_malloc+0x95)[0xb7e8f9c5]
./a.out[0x804a8ab]
./a.out[0x804bb52]
./a.out[0x804ba3d]
./a.out[0x804ba3d]
./a.out[0x804ba3d]
./a.out[0x804ba3d]
./a.out[0x804ba3d]
./a.out[0x804ba3d]
./a.out[0x8049e32]
./a.out[0x8048892]
/lib/tls/i686/cmov/libc.so.6(__lib c_start_main+0x e5)[0xb7e32775]
./a.out[0x8048401]
and other stuff... can It be becouse it is a recursive function?
the second and biggest problem is that when the number becomes too large (something like 1000 digits) I get a segmentation fault... there are strange problems with arrays of this dimension?
the code is very big but you can find it at:
ps: I've deleted the free() functions... It caused too many errors...
thanks for you help, and sorry for my eng...
Comment