/* gcc -o test `pkg-config --cflags --libs glib-2.0` test.c */

#include <stdio.h>
#include <glib.h>

int main (int argc, char **argv)
{
  guint8 *buffer;
  GByteArray *array;

  /* Buffer with 1 byte */
  buffer = g_malloc (1);
  buffer[0] = 0xAB;
  /* Create GByteArray from the buffer */
  array = g_byte_array_new_take (buffer, 1);
  /* Check that the first byte is the one expected */
  g_assert (array->data[0] == 0xAB);
  /* Increase size of the array in 1 byte */
  g_byte_array_set_size (array, array->len + 1);
  /* Check that the first byte is still the one expected */
  g_assert (array->data[0] == 0xAB);
  g_byte_array_unref (array);

  return 0;
}
