Hi Steve,
On 11/5/2012 9:36 PM, Steve Prior wrote:
> I'm having trouble porting some old ACE/TAO code to a new system running Ubuntu
> 12.02 64 bit with TAO 2.0.1.
>
> using the following IDL:
>
> module Smrthm
> {
> interface Video {
> typedef sequence<octet> Picture;
> Picture TakeSnapshot();
> };
> };
>
> The following code coredumps in the memcpy:
>
> Smrthm::Video::Picture_var theSnapshot = video->TakeSnapshot();
> long pictureLength = theSnapshot->length();
> cerr << "allocating buffer of size:" << pictureLength << "\n";
> void *buffer = malloc(pictureLength);
> cerr << "allocated buffer\n";
> memcpy(buffer, theSnapshot->get_buffer(1), pictureLength);
> cerr << "memcpy complete\n";
>
> So I suspect I'm doing something wrong around theSnapshot->get_buffer(1), but
> I'm not sure what. Can someone point me to an example of how you're supposed to
> access the data of a sequence<octet>?
I don't know of any reason to pass 1 (actually, "true") as the argument
to get_buffer(1) for this read-only use case. Instead just let the
default parameter take effect and call get_buffer().
Thanks,
Adam Mitz
Senior Software Engineer
Object Computing, Inc.