R: strint <--> octect problem



Hi,
first of all I want to say thank you to Mark for his help.
I implemented the changes suggested but nothing changed: when the string is
longer than about 20 char, my system crashes; when it's less than 20, all
it's ok.

I re-post my code(modified following Mark helps): it's something like that:

  CORBA_char* message ="Bla bla bla 123456789012XXX";
  CORBA_char* msgstring;
  DispatcherDataQueue_mem * msg;     /* Sequence of octet */

  //Insert the strings in the octet sequences
   msg = DispatcherDataQueue_mem__alloc();
   msg->_length = strlen(message)+1;
   msg->_maximum = msg->_length;

   msg->_buffer = CORBA_sequence_CORBA_octet_allocbuf(msg->_length);
   for (i=0; i<msg->_length ; i++)
	   msg->_buffer[i] = (CORBA_octet) message[i];

   CORBA_sequence_set_release(msg, FALSE);  // <-- SUGGESTED ME BY MARK
MCLOUGHLIN

   printf("The string read is %s.\n",(CORBA_char *)msg->_buffer);

	...<snip>...

	// WHEN I RECEIVE THE OCTECT BACK, I OUTPUT IT IN THIS WAY:
    printf("The message read length is %i\n", msg->_length);
    printf("The message read is %s.\n",(CORBA_char*)msg->_buffer);
    msg->_release=CORBA_TRUE;
    CORBA_free(msg3);


Please HELP ME!!
Any suggetion is really wellcome!

Thanks
Samuele


-----Messaggio originale-----
Da: orbit-list-admin@gnome.org [mailto:orbit-list-admin@gnome.org]Per
conto di Mark McLoughlin
Inviato: domenica 9 dicembre 2001 16.58
A: orbit-list@gnome.org
Oggetto: Re: strint <--> octect problem


Hey Samuele,

On Sun, 9 Dec 2001, Samuele Gallazzi wrote:

>   //Insert the strings in the octet sequences
>    msg = DispatcherDataQueue_mem__alloc();
>    msg->_length = strlen(message)+1;
>    msg->_maximum = msg->_length;

	you need to set msg->_release to FALSE here to let the ORB
know not to free the data (since you have it statically allocated).
The correct way to do this is using CORBA_sequence_set_release.

Good Luck,
Mark.

_______________________________________________
orbit-list mailing list
orbit-list@gnome.org
http://mail.gnome.org/mailman/listinfo/orbit-list




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]