Repository: xbmc/xbmc
File: xbmc-xrandr.c (C)

Code before:
    set_name_string(name, string);
  else
    usage();
}

static void init_transform(transform_t* transform)
{
  int x;
  memset(&transform->transform, '\0', sizeof(transform->transform));
  for (x = 0; x < 3; x++)
    transform->transform.matrix[x][x] = XDoubleToFixed(1.0);
  transform->filter = "";
  transform->nparams = 0;
  transform->params = NULL;
}

static void set_transform(
    transform_t* dest, XTransform* transform, char* filter, XFixed* params, int nparams)
{
  dest->transform = *transform;
  dest->filter = strdup(filter);
  dest->nparams = nparams;
  dest->params = malloc(nparams * sizeof(XFixed));
  if (nparams)
    memcpy(dest->params, params, nparams * sizeof(XFixed));
}

static void copy_transform(transform_t* dest, transform_t* src)
{
  set_transform(dest, &src->transform, src->filter, src->params, src->nparams);
}

static Bool equal_transform(transform_t* a, transform_t* b)
{
  if (memcmp(&a->transform, &b->transform, sizeof(XTransform)) != 0)
    return False;
  if (strcmp(a->filter, b->filter) != 0)
    return False;
  if (a->nparams != b->nparams)
    return False;
  if (memcmp(a->params, b->params, a->nparams * sizeof(XFixed)) != 0)
    return False;
  return True;
}

static output_t* add_output(void)
{
  output_t* output = calloc(1, sizeof(output_t));

  if (!output)
    fatal("out of memory\n");

Review comment (suggestion):
Calling `malloc` with size 0 is implementation defined. Better change it to this for predictable behavior:
```cpp
static void set_transform(
    transform_t* dest, XTransform* transform, char* filter, XFixed* params, int nparams)
{
  dest->transform = *transform;
  dest->filter = strdup(filter);
  dest->nparams = nparams;
  if (nparams)
  {
    dest->params = malloc(nparams * sizeof(XFixed));
    memcpy(dest->params, params, nparams * sizeof(XFixed));
  }
  else
    dest->params = NULL;
}
```

Code after:
    set_name_string(name, string);
  else
    usage();
}

static void init_transform(transform_t* transform)
{
  int x;
  memset(&transform->transform, '\0', sizeof(transform->transform));
  for (x = 0; x < 3; x++)
    transform->transform.matrix[x][x] = XDoubleToFixed(1.0);
  transform->filter = "";
  transform->nparams = 0;
  transform->params = NULL;
}

static void set_transform(
    transform_t* dest, XTransform* transform, char* filter, XFixed* params, int nparams)
{
  dest->transform = *transform;
  dest->filter = strdup(filter);
  dest->nparams = nparams;
  if (nparams)
  {
    dest->params = malloc(nparams * sizeof(XFixed));
    memcpy(dest->params, params, nparams * sizeof(XFixed));
  }
  else
    dest->params = NULL;
}

static void copy_transform(transform_t* dest, transform_t* src)
{
  set_transform(dest, &src->transform, src->filter, src->params, src->nparams);
}

static Bool equal_transform(transform_t* a, transform_t* b)
{
  if (memcmp(&a->transform, &b->transform, sizeof(XTransform)) != 0)
    return False;
  if (strcmp(a->filter, b->filter) != 0)
    return False;
  if (a->nparams != b->nparams)
    return False;
  if (memcmp(a->params, b->params, a->nparams * sizeof(XFixed)) != 0)
    return False;
  return True;
}

static output_t* add_output(void)
{