title: how to calculate required memory for a signal or structure in C
body: <p>I have recently started to work in C. I was going through some code exercises to get some knowledge about signals. I know that <code>alloc()</code> is used to allocate memory for signals. in the following code <code>len</code> is my <code>data_len</code> which is defined in the structure. Have a look to the following scenario.  </p>
  
  <pre><code>#define DATA_SEND   (SIGBASE + 1)
  struct data_send
  {
    uint32_t       sig_no  ;
    uint32_t       seq_no  ;
    uint32_t       data_len;
    uint32_t       type    ;   
    char           data[1] ;    
  };
  
  signal = (struct data_send *) alloc(sizeof(struct data_send) + len - 1,
             DATA_SEND);
  </code></pre>
  
  <p>My question is why do we do <code>+len and -1</code> while allocating memory for this signal. When we do <code>sizeof(struct data_send)</code> we are allocating memory for all the variables in the structure. Does this <code>-1</code> has to do anything with <code>data[1]</code> ? could someone explain to me the reason to have <code>+len and -1</code>.</p>