我在处理单词(2字节无符号整数)时遇到了一个问题。以下是我通常运行的命令
import mySimLib
mySimLib.init()
strPtr = mySimLib.strInit( 200 ) #where 200 is the number of characters I want in the
#string. strInit returns a malloc'd pointer
wPtr = mySimLib.wordInit () # where wordInit returns a malloc'd pointer to a WORD.
mySimLib.Write ("Title", "Data", 4) # 4 is the number of bytes required to store data
mySimLib.Search ("Title", strPtr, 200, wPtr) #Search finds the record with same title,
#copies the data into strPtr up to the number of bytes in the record - as long as
#the number of bytes in the strPtr is greater.
mySimLib.printWord (wPtr) #Since I cannot use python to dereference word pointers, I call a C function to print it out.
此时,我的程序崩溃了。它抛出异常(读取冲突)或某些GC对象已跟踪错误。问题是-我有一个字符串打印函数,当我打印它时,它永远不会失败。当我试图把这个词打印出来时,我确实会出错。在
这是我的wordptr初始化函数:
^{pr2}$这是我的打印功能:
void wordPrint (unsigned int * d){
printf ("\nWptr: %d",*d);
}
我不知道我做错了什么,但这些碰撞是非常不稳定和恼人的。在
目前没有回答
相关问题 更多 >
编程相关推荐