static OggzComment *
oggz_comment_new (const char * name, const char * value)
{
  OggzComment * comment;

  if (!oggz_comment_validate_byname (name)) return NULL;
  /* Ensures that name != NULL and contains only valid characters */

  comment = oggz_malloc (sizeof (OggzComment));
  if (comment == NULL) return NULL;

  comment->name = oggz_strdup (name);
  if (comment->name == NULL) {
    oggz_free (comment);
    return NULL;
  }

  if (value) {
    comment->value = oggz_strdup (value);
    if (comment->value == NULL) {
      oggz_free (comment->name);
      oggz_free (comment);
      return NULL;
    }
  } else {
    comment->value = NULL;
  }

  return comment;
}
Exemple #2
0
static OggzComment *
oggz_comment_new (const char * name, const char * value)
{
    OggzComment * comment;

    if (!oggz_comment_validate_byname (name, value)) return NULL;

    comment = oggz_malloc (sizeof (OggzComment));
    comment->name = oggz_strdup (name);
    comment->value = oggz_strdup (value);

    return comment;
}
Exemple #3
0
static int
_oggz_comment_set_vendor (OGGZ * oggz, long serialno,
                          const char * vendor_string)
{
    oggz_stream_t * stream;

    if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ;

    stream = oggz_get_stream (oggz, serialno);
    if (stream == NULL) return OGGZ_ERR_BAD_SERIALNO;

    if (stream->vendor) oggz_free (stream->vendor);

    stream->vendor = oggz_strdup (vendor_string);

    return 0;
}