title: Google Protobuf-c repeated strings
body: <p>My Google protobuf-c proto file looks like this:</p>
  
  <pre><code>message foo{
    required uint32 addresscount= 1;
    repeated string destination_hops= 2;
  }
  </code></pre>
  
  <p>I want an array of strings and <code>addresscount</code> is supposed to give the count of array elements.</p>
  
  <p>The generated protobuf-h file is </p>
  
  <pre><code>struct  _foo
     {
     ProtobufCMessage base;
     uint32_t addresscount;
     size_t n_destination_hops;
     char **destination_hops;
     };
  </code></pre>
  
  <p>I assume that n_destination_hops is the number of times the string destination_hops appears in the message. I had kept addresscount for that purpose and i guess thats not required. My question is this:</p>
  
  <p><code>char **destination_hops</code> is a pointer to an array of <code>char *</code> pointers. Each index can be of different length. How will protobuf know the size of each <code>char *</code> pointer when it has packed this into a stream. Does protobuf assume that all destination_hops would be of the same size and is that given by <code>size_t n_destination_hops</code>?</p>
  
  <p>DOUBT 2:</p>
  
  <p><code>char ** destination_hops</code> is an array of <code>char *</code> pointers.</p>
  
  <p>This means i can look at it as <code>char *destination_hops[0]</code>, <code>char *destination_hops[1]</code>, etc</p>
  
  <p>If this is correct then shouldn't i be able to set <code>char *destination_hops[0] = "abc"</code>. </p>
  
  <p>When i do that i get a segmentation fault.</p>
  
  <p>Any idea why?</p>