C-API: A beginner's problem

Fabian Steiner lists at fabis-site.net
Sun Mar 19 18:34:15 CET 2006

Heikki Salo wrote:
> Heikki Salo wrote:
>> Fabian Steiner wrote:
>>> What did I do wrong? As I am quite new to C, I probably made many 
>>> mistakes, so please feel free to correct me.
>> The following line:
>>  >     for (i = 0; i <= seqlen; i++) {
>> Should be "for (i = 0; i < seqlen; i++) {". Otherwise the last 
>> assignment will be out of bounds and probably corrupts heap.
> And closer look tells that the code should not even compile. Is the code 
> cut & pasted directly? Line "list[i] = item;" tries to assign a pointer 
> to an int-array, which should not compile. There are other similar 
> oddities.

Okay, thank you (and the others) for these hints. As you see, I am quite 
new to C and I just wrote these lines by using parts I have found in the 
newsgroup. Unfortunately, the Python C-API documentation / tutorial 
won't help me since it is quite difficult to understand because of the 
lack of basics.

What do I have to change in order to make the code work?

Thank you very much in advance!


More information about the Python-list mailing list