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();
rf->Reserve(count);
int i;
for (i = 0; i < count; i++) {
    rf->AddAlreadyReserved();
}
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++) {
    rf->AddAlreadyReserved(buf[i]);
}
Again, I'd rather set the size and use a fast memcpy.

Thanks,
Piquan

-- 
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 protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at http://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to