diff options
| author | xHire <xhire@tuxportal.cz> | 2008-10-25 14:11:06 +0200 |
|---|---|---|
| committer | xHire <xhire@tuxportal.cz> | 2008-10-25 14:11:06 +0200 |
| commit | c8a9209d77a896bf49227e5aeccd54e91ccf29cc (patch) | |
| tree | 6b7367406ebbc6ce3ea5e0c8668c75f6fb3f6ae9 /src/base/storage.c | |
| parent | cb9deba915dd7b114eeb76601eb1c8b07c1ba90f (diff) | |
Changed style of the code to the K&R standard
Diffstat (limited to 'src/base/storage.c')
| -rw-r--r-- | src/base/storage.c | 185 |
1 files changed, 88 insertions, 97 deletions
diff --git a/src/base/storage.c b/src/base/storage.c index ca55bc4..1ae5f5a 100644 --- a/src/base/storage.c +++ b/src/base/storage.c @@ -7,127 +7,118 @@ #include "main.h" #include "list.h" -typedef struct struct_storage_item -{ - char *name; - char *group; - void *data; +typedef struct struct_storage_item { + char *name; + char *group; + void *data; } storage_item_t; -list_t * -newStorage() +list_t *newStorage() { - return newList(); + return newList(); } -static storage_item_t * -newStorageItem(char *group, char *name, void *data) +static storage_item_t *newStorageItem(char *group, char *name, void *data) { - storage_item_t *new; - - assert(name != NULL); - assert(group != NULL); - assert(data != NULL); - new = malloc(sizeof(storage_item_t)); - new->name = strdup(name); - new->group = strdup(group); - new->data = data; - return new; + storage_item_t *new; + + assert(name != NULL); + assert(group != NULL); + assert(data != NULL); + new = malloc(sizeof(storage_item_t)); + new->name = strdup(name); + new->group = strdup(group); + new->data = data; + return new; } -static void -destroyStorageItem(storage_item_t * p, void *f) +static void destroyStorageItem(storage_item_t * p, void *f) { - void (*fce) (void *); - - assert(p != NULL); - assert(f != NULL); - fce = f; - fce(p->data); - free(p->name); - free(p->group); - free(p); + void (*fce) (void *); + + assert(p != NULL); + assert(f != NULL); + fce = f; + fce(p->data); + free(p->name); + free(p->group); + free(p); } -void -addItemToStorage(list_t * list, char *group, char *name, void *data) +void addItemToStorage(list_t * list, char *group, char *name, void *data) { - assert(list != NULL); - assert(group != NULL); - assert(name != NULL); - addList(list, newStorageItem(group, name, data)); + assert(list != NULL); + assert(group != NULL); + assert(name != NULL); + addList(list, newStorageItem(group, name, data)); } -void * -getItemFromStorage(list_t * list, char *group, char *name) +void *getItemFromStorage(list_t * list, char *group, char *name) { - storage_item_t *this; - int i; - - assert(list != NULL); - assert(group != NULL); - assert(name != NULL); - for (i = 0; i < list->count; i++) { - this = (storage_item_t *) list->list[i]; - if (strcmp(group, this->group) == 0 && strcmp(name, this->name) == 0) - return this->data; - } + storage_item_t *this; + int i; + + assert(list != NULL); + assert(group != NULL); + assert(name != NULL); + for (i = 0; i < list->count; i++) { + this = (storage_item_t *) list->list[i]; + if (strcmp(group, this->group) == 0 && strcmp(name, this->name) == 0) + return this->data; + } #ifdef DEBUG - printf(_("%s %s was not found in storage!\n"), group, name); + printf(_("%s %s was not found in storage!\n"), group, name); #endif - return NULL; + return NULL; } -void -delItemFromStorage(list_t * list, char *group, char *name, void *f) +void delItemFromStorage(list_t * list, char *group, char *name, void *f) { - storage_item_t *this; - int i; - - assert(list != NULL); - assert(group != NULL); - assert(name != NULL); - for (i = 0; i < list->count; i++) { - this = (storage_item_t *) list->list[i]; - if (strcmp(group, this->group) == 0 && strcmp(name, this->name) == 0) { - destroyStorageItem(this, f); - delList(list, i); - return; - } - } - return; + storage_item_t *this; + int i; + + assert(list != NULL); + assert(group != NULL); + assert(name != NULL); + for (i = 0; i < list->count; i++) { + this = (storage_item_t *) list->list[i]; + if (strcmp(group, this->group) == 0 && strcmp(name, this->name) == 0) { + destroyStorageItem(this, f); + delList(list, i); + return; + } + } + return; } -void -delAllItemFromStorage(list_t * list, char *group, void *f) +void delAllItemFromStorage(list_t * list, char *group, void *f) { - storage_item_t *this; - int i; - - assert(list != NULL); - assert(group != NULL); - - for (i = 0; i < list->count; i++) { - this = (storage_item_t *) list->list[i]; - if (strcmp(group, this->group) == 0) { - destroyStorageItem(this, f); - delList(list, i); - i--; - } - } + storage_item_t *this; + int i; + + assert(list != NULL); + assert(group != NULL); + + for (i = 0; i < list->count; i++) { + this = (storage_item_t *) list->list[i]; + if (strcmp(group, this->group) == 0) { + destroyStorageItem(this, f); + delList(list, i); + i--; + } + } } -void -destroyStorage(list_t * p, void *f) +void destroyStorage(list_t * p, void *f) { - storage_item_t *this; - int i; - - assert(p != NULL); - assert(f != NULL); - for (i = 0; i < p->count; i++) { - this = (storage_item_t *) p->list[i]; - destroyStorageItem(this, f); - } - destroyList(p); + storage_item_t *this; + int i; + + assert(p != NULL); + assert(f != NULL); + for (i = 0; i < p->count; i++) { + this = (storage_item_t *) p->list[i]; + destroyStorageItem(this, f); + } + destroyList(p); } |