int main(void) { page_attribute a, b; size_t i, niter = 10000; const char* media_type = "text/html"; const char* language = "en_uk"; const char* charset = "iso8859-1"; const char* encoding = "gzip"; for (i = 0; i < niter; i++) { if ((a = attribute_new()) == NULL) return 77; if (!attribute_set_media_type(a, media_type)) return 77; if (!attribute_set_language(a, language)) return 77; if (!attribute_set_charset(a, charset)) return 77; if (!attribute_set_encoding(a, encoding)) return 77; if (strcmp(attribute_get_media_type(a), media_type) != 0) return 77; if (strcmp(attribute_get_language(a), language) != 0) return 77; if (strcmp(attribute_get_charset(a), charset) != 0) return 77; if (strcmp(attribute_get_encoding(a), encoding) != 0) return 77; if ((b = attribute_dup(a)) == NULL) return 77; if (strcmp(attribute_get_media_type(b), media_type) != 0) return 77; if (strcmp(attribute_get_language(b), language) != 0) return 77; if (strcmp(attribute_get_charset(b), charset) != 0) return 77; if (strcmp(attribute_get_encoding(b), encoding) != 0) return 77; attribute_free(a); attribute_free(b); } return 0; }
int dynamic_set_attributes(dynamic_page p, page_attribute a) { attribute_free(p->attr); if( (p->attr = attribute_dup(a)) == NULL) return ENOMEM; return 0; }
void dynamic_free(dynamic_page p) { assert(NULL != p); if(p != NULL) { attribute_free(p->attr); cstring_free(p->uri); free(p); } }
static void relation_free(relation_t *rel) { attribute_t *attr; while((attr = list_pop(rel->attributes)) != NULL) { attribute_free(rel, attr); } list_remove(relations, rel); memb_free(&relations_memb, rel); }
scew_attribute* attribute_list_add(attribute_list* list, scew_attribute* attribute) { scew_attribute* aux = NULL; assert(list != NULL); assert(attribute != NULL); aux = attribute_by_name(list, attribute->name); if (aux != NULL) { if (aux->prev != NULL) { aux->prev->next = attribute; } if (aux->next != NULL) { aux->next->prev = attribute; } if (list->first == aux) { list->first = attribute; } if (list->last == aux) { list->last = attribute; } attribute->prev = aux->prev; attribute->next = aux->next; attribute_free(aux); return attribute; } list->size++; if (list->first == NULL) { list->first = attribute; } else { list->last->next = attribute; attribute->prev = list->last; } list->last = attribute; return attribute; }
page_attribute attribute_dup(page_attribute a) { page_attribute p; if ((p = attribute_new()) == NULL) return NULL; if (!cstring_set(p->language, c_str(a->language)) || !cstring_set(p->charset, c_str(a->charset)) || !cstring_set(p->encoding, c_str(a->encoding)) || !cstring_set(p->media_type, c_str(a->media_type))) { attribute_free(p); return NULL; } return p; }
void attribute_list_del(attribute_list* list, XML_Char const* name) { scew_attribute* attribute = NULL; scew_attribute* tmp_prev = NULL; scew_attribute* tmp_next = NULL; if ((list == NULL) || (name == NULL)) { return; } attribute = attribute_by_name(list, name); if (attribute != NULL) { tmp_prev = attribute->prev; tmp_next = attribute->next; if (tmp_prev != NULL) { tmp_prev->next = tmp_next; } if (tmp_next != NULL) { tmp_next->prev = tmp_prev; } if (attribute == list->first) { list->first = tmp_next; } if (attribute == list->last) { list->last = tmp_prev; } attribute_free(attribute); list->size--; } }
void attribute_list_free(attribute_list* list) { scew_attribute* it = NULL; scew_attribute* tmp = NULL; if (list == NULL) { return; } it = list->first; while (it != NULL) { tmp = it; it = it->next; attribute_free(tmp); } free(list); }
db_result_t relation_attribute_remove(relation_t *rel, char *name) { /* Not implemented completely. */ return DB_IMPLEMENTATION_ERROR; #if 0 attribute_t *attr; if(rel->references > 1) { return DB_BUSY_ERROR; } attr = relation_attribute_get(rel, name); if(attr == NULL) { return DB_NAME_ERROR; } list_remove(rel->attributes, attr); attribute_free(rel, attr); return DB_OK; #endif }