0
我目前的结构正确影响stuct指针的值
struct Protocol__ChecksumTable
{
ProtobufCMessage base;
uint32_t tableindex;
size_t n_entry;
Protocol__ChecksumEntry **entry;
};
struct Protocol__ChecksumEntry
{
ProtobufCMessage base;
uint32_t index;
uint32_t value;
};
现在我宣布Protocol__ChecksumTable*
结构由函数填充它返回一个Protocol__ChecksumTable*
Protocol__ChecksumTable *
protocol__checksum_tables_response__unpack(void);
...
Protocol__ChecksumTable * checksumTablesResponse;
checksumTablesResponse = protocol__checksum_tables_response__unpack();
现在我想修改Protocol__ChecksumEntry
上的字段条目如下:
checksumTablesResponse->entry[0]->value = value;
返回的值不为空,因为我可以正确地记录它:
for (index = 0; index < checksumTablesResponse->n_entry; index ++) {
LOG("checksumTablesResponse->entry[index]->value);
}
7值将显示:
3054867360
3054867360
379899191
4128997118
3185498542
1736976844
2545413521
但随后的程序崩溃!
有什么问题?
** 1 **'checksumTablesResponse'是一个指针,是不是'NULL'? ** 2。**'(...) - > entry'是一个数组,它的大小是否至少为1? ** 3。**'(...) - > entry [0]'是一个指针,它不是'NULL'吗? –
是(不)你错过了'typedef'的几个,至少? –
@AndreKampling我更新了问题 – mikmak