Mercurial > hg > freeDiameter
comparison libfdproto/dictionary.c @ 778:003df4a9ade2
Added two new interfaces on Zach requests http://lists.freediameter.net/pipermail/help/2012-January/000312.html and http://lists.freediameter.net/pipermail/help/2012-January/000311.html
author | Sebastien Decugis <sdecugis@nict.go.jp> |
---|---|
date | Sat, 21 Jan 2012 16:11:34 +0100 |
parents | 27fef2ca2cf6 |
children | cb84f5be889d |
comparison
equal
deleted
inserted
replaced
777:cfc714065cb8 | 778:003df4a9ade2 |
---|---|
1809 error_free: | 1809 error_free: |
1810 free(new); | 1810 free(new); |
1811 return ret; | 1811 return ret; |
1812 } | 1812 } |
1813 | 1813 |
1814 | |
1815 int fd_dict_delete(struct dict_object * obj) | |
1816 { | |
1817 int i; | |
1818 struct dictionary * dict; | |
1819 int ret=0; | |
1820 | |
1821 /* check params */ | |
1822 CHECK_PARAMS( verify_object(obj) && obj->dico); | |
1823 dict = obj->dico; | |
1824 | |
1825 /* Lock the dictionary for change */ | |
1826 CHECK_POSIX( pthread_rwlock_wrlock(&dict->dict_lock) ); | |
1827 | |
1828 /* check the object is not sentinel for another list */ | |
1829 for (i=0; i<NB_LISTS_PER_OBJ; i++) { | |
1830 if (!_OBINFO(obj).haslist[i] && !(FD_IS_LIST_EMPTY(&obj->list[i]))) { | |
1831 /* There are children, this is not good */ | |
1832 ret = EINVAL; | |
1833 TRACE_DEBUG (FULL, "Cannot delete object, list %d not empty:", i); | |
1834 #if 0 | |
1835 dump_list(&obj->list[i], 0,0,0); | |
1836 #endif | |
1837 break; | |
1838 } | |
1839 } | |
1840 | |
1841 /* ok, now destroy the object */ | |
1842 if (!ret) | |
1843 destroy_object(obj); | |
1844 | |
1845 /* Unlock */ | |
1846 CHECK_POSIX( pthread_rwlock_unlock(&dict->dict_lock) ); | |
1847 | |
1848 return ret; | |
1849 } | |
1850 | |
1851 | |
1814 int fd_dict_search ( struct dictionary * dict, enum dict_object_type type, int criteria, void * what, struct dict_object **result, int retval ) | 1852 int fd_dict_search ( struct dictionary * dict, enum dict_object_type type, int criteria, void * what, struct dict_object **result, int retval ) |
1815 { | 1853 { |
1816 int ret = 0; | 1854 int ret = 0; |
1817 | 1855 |
1818 TRACE_ENTRY("%p %d(%s) %d %p %p %d", dict, type, dict_obj_info[CHECK_TYPE(type) ? type : 0].name, criteria, what, result, retval); | 1856 TRACE_ENTRY("%p %d(%s) %d %p %p %d", dict, type, dict_obj_info[CHECK_TYPE(type) ? type : 0].name, criteria, what, result, retval); |