opensourcerouting / c-capnproto

C library/compiler for the Cap'n Proto serialization/RPC protocol
MIT License
118 stars 40 forks source link

capn_get64() always returns zero #51

Closed elagil closed 3 months ago

elagil commented 2 years ago

Hello!

I want to perform element-wise reading on a capn_list64. I have a problem with capn_get64(), which always returns a zero value, whereas capn_getv64() works fine. What could be the reason?

I test as follows:

uint64_t sample_get = capn_get64(samples, sample_index);

uint64_t sample_getv;
capn_getv64(samples, sample_index, &sample_getv, 1);

In the above example, sample_get = 0, but sample_getv = 4625979026566705573, which is the number that I stored in the first place.

Thanks in advance!

elagil commented 2 years ago

I found that I have to call capn_resolve(&(samples.p)) first, for capn_get64() to work, but I don't understand why. I guess capn_get*() does not call it automatically, because it would be redundant if you call it a large number of times. Is that assumption correct?