Changeset ea186c6 in mainline for uspace/srv/loc/category.c
- Timestamp:
- 2011-08-18T20:27:26Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 921b84f
- Parents:
- 1f44b056 (diff), ef7052ec (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/loc/category.c
r1f44b056 rea186c6 93 93 cat->id = loc_create_id(); 94 94 link_initialize(&cat->cat_list); 95 list_initialize(&cat->s ervices);95 list_initialize(&cat->svc_memb); 96 96 } 97 97 … … 113 113 { 114 114 assert(fibril_mutex_is_locked(&cat->mutex)); 115 assert(fibril_mutex_is_locked(&services_list_mutex)); 115 116 116 117 /* Verify that category does not contain this service yet. */ 117 list_foreach(cat->services, item) { 118 119 loc_service_t *csvc = list_get_instance(item, loc_service_t, 120 cat_services); 121 if (csvc == svc) { 118 list_foreach(cat->svc_memb, item) { 119 svc_categ_t *memb = list_get_instance(item, svc_categ_t, 120 cat_link); 121 if (memb->svc == svc) { 122 122 return EEXIST; 123 123 } 124 124 } 125 125 126 list_append(&svc->cat_services, &cat->services); 126 svc_categ_t *nmemb = malloc(sizeof(svc_categ_t)); 127 if (nmemb == NULL) 128 return ENOMEM; 129 130 nmemb->svc = svc; 131 nmemb->cat = cat; 132 133 list_append(&nmemb->cat_link, &cat->svc_memb); 134 list_append(&nmemb->svc_link, &svc->cat_memb); 135 127 136 return EOK; 137 } 138 139 /** Remove service from category. */ 140 void category_remove_service(svc_categ_t *memb) 141 { 142 assert(fibril_mutex_is_locked(&memb->cat->mutex)); 143 assert(fibril_mutex_is_locked(&services_list_mutex)); 144 145 list_remove(&memb->cat_link); 146 list_remove(&memb->svc_link); 147 148 free(memb); 128 149 } 129 150 … … 169 190 buf_cnt = buf_size / sizeof(service_id_t); 170 191 171 act_cnt = list_count(&cat->s ervices);192 act_cnt = list_count(&cat->svc_memb); 172 193 *act_size = act_cnt * sizeof(service_id_t); 173 194 … … 176 197 177 198 size_t pos = 0; 178 list_foreach(cat->s ervices, item) {179 loc_service_t *svc=180 list_get_instance(item, loc_service_t, cat_services);199 list_foreach(cat->svc_memb, item) { 200 svc_categ_t *memb = 201 list_get_instance(item, svc_categ_t, cat_link); 181 202 182 203 if (pos < buf_cnt) 183 id_buf[pos] = svc->id;204 id_buf[pos] = memb->svc->id; 184 205 pos++; 185 206 }
Note:
See TracChangeset
for help on using the changeset viewer.