Esempio n. 1
0
int
oggz_comment_remove (OGGZ * oggz, long serialno, OggzComment * comment)
{
    oggz_stream_t * stream;
    OggzComment * v_comment;

    if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ;

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

    if (oggz->flags & OGGZ_WRITE) {
        if (OGGZ_CONFIG_WRITE) {
            v_comment = oggz_vector_find_p (stream->comments, comment);

            if (v_comment == NULL) return 0;

            oggz_vector_remove_p (stream->comments, v_comment);
            oggz_comment_free (v_comment);

            return 1;

        } else {
            return OGGZ_ERR_DISABLED;
        }
    } else {
        return OGGZ_ERR_INVALID;
    }
}
Esempio n. 2
0
void *
oggz_table_insert (OggzTable * table, long key, void * data)
{
  void * old_data;

  if ((old_data = oggz_table_lookup (table, key)) != NULL) {
    if (oggz_vector_remove_l (table->keys, key) == NULL)
      return NULL;

    if (oggz_vector_remove_p (table->data, old_data) == NULL) {
      /* XXX: This error condition can only happen if the previous
       * removal succeeded, and this removal failed, ie. there was
       * an error reallocing table->data->data downwards. */
      return NULL;
    }
  }

  if (oggz_vector_insert_l (table->keys, key) == -1)
    return NULL;
  
  if (oggz_vector_insert_p (table->data, data) == NULL) {
    oggz_vector_remove_l (table->keys, key);
    return NULL;
  }

  return data;
}