This is on Protobuf 2.5.0 under C++.

I'm loading an array of uint32s into a repeated field.  The array is in 
device memory, so I have to copy it into host memory before I can hand it 
off to Protobuf.  I can copy straight into the RepeatedField's 
mutable_data, but I don't see a way to adjust the size efficiently.  The 
only ways I see to increment the size of a field is one at a time.

As it currently stands, I'm doing (roughly) this:

google::protobuf::RepeatedField<uint32>* rf = myproto->mutable_foo();
int i;
for (i = 0; i < count; i++) {
uint32* md = rf->mutable_data();
copy_from_device_memory(md, device_address, count * sizeof(*md));

(I've simplified the code to show just the issue at hand, so forgive any 
syntax errors.)

I have another routine that is very similar, but the data is already in 
host memory, so I'm adding the data using:
for (i = 0; i < count; i++) {
Again, I'd rather set the size and use a fast memcpy.


You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
To post to this group, send email to
Visit this group at
For more options, visit

Reply via email to