title: Implementation of generic struct with header
body: <p>I'm a little confused about it.
  The exercise is very long so I hope I wrote everything that's relevant for my question.
  I have a given header file (part of it):</p>
  <pre><code>typedef void *(*copy_element)(const void *);
  typedef void *(*free_element)(void **);
  
  typedef struct group {
      size_t group_size;
      void **data;
      copy_element copy_element_func;
      free_element free_element_func;
  } group;
  
  group *group_alloc(copy_element copy_element_func, free_element free_element_func);
  void group_free(group **p);
  int add(group *group, const void *value);
  </code></pre>
  <p>I need to implement <code>group.c</code> as a generic struct.
  My question is how can I implement add and alloc functions for <code>**data</code>?
  With a known type I would use malloc and realloc with the size of the type, but here I'm not sure what to do.</p>
  <pre><code>group *group_alloc() {
      group *p = malloc(sizeof(group))
      if(p == NULL) {
          //
      }
      p-&gt;group_size = 0;
  
      void **ptr = malloc(sizeof(void*));
      p-&gt;data = ptr;
      return p;
  }
  </code></pre>
  <p>In the exercise, Group should contain a dynamic array of values.</p>
  <p>Thanks!</p>