Hi Folks,

In my case i am passing the void pointer which will be assigned with some memory to the firmware; in return firmware will fill this void pointer and returns.
My requirement is i have parse this filled data. But data filled by the firmware is complex.

e.g it will have following type of data :

   total_size_filled  4 byte;
   Num_param          4 byte;
   struct2             VARIABLE SIZE;

   size       4byte;
   type       4 byte;
   if(type == type1)
      struct_type1;       VARIABLE SIZE
   else if(type == type2)
      struct_type2;       VARIABLE SIZE

// consider type == type1

   some_struct      12 byte;
   struct_type1_1   VARIABLE;
   struct_type1_2   VARIABLE;

   some_var         4 byte;
   some_struct      16 byte;

   some_var         2 byte;
   some_var         2 byte;
   some_struct      20 byte;

Now i have to parse the above filled data.. Can you please suggest me something..
Can i use tree or vector to ???

Don't use structures before reading the data, create a program to parse the data and load them into your OWN structures which you made.

So you read the blocks of data one known element at a time, and only copy the data you NEED for your program into your structures.

void *FirmwareStruct2 = GetFromFirmware();
void *s2ptr = FirmwareStruct2;

int Size = ((int *)(s2ptr + 0))[0];
int Type = ((int *)(s2ptr + 4))[0];

s2ptr = s2ptr + 8; // Now s2ptr points to the following struct_type

switch (Type) {
  case 1: // struct_type1
    // Load data the same way I did before
  case 2: // struct_type2
    // Load data the same way I did before
This article has been dead for over six months. Start a new discussion instead.