ctypes - python2.7.3 vs python3.2.3

Jan Kuiken jan.kuiken at quicknet.nl
Wed Aug 29 17:25:47 EDT 2012


On 8/28/12 23:51 , John Gordon wrote:
> In <18eb8025-7545-4d10-9e76-2e41deaadb69 at googlegroups.com> Rolf <rolfb at personalized-books.com> writes:
>
>> uint32_t myfunction (char ** _mydata)
>> {
>>     char mydata[16];
>
>>     strcpy(mydata, "Hello Dude!");
>
>>     *_mydata = mydata;
>
>>     return 0;
>> }
>
> mydata is an auto variable, which goes out of scope when myfunction()
> exits.  *_mydata ends up pointing to garbage.
>

I'm not completely sure, but i think this can be solved by using:

     static char mydata[16];

(Btw.: I don't know why you use char ** _mydata, i would use
        char * _mydata, but then again, i'm not very familiar with
        ctypes)

Jan Kuiken




More information about the Python-list mailing list