diff options
author | Luke Leighton <lkcl@samba.org> | 1999-12-01 02:15:14 +0000 |
---|---|---|
committer | Luke Leighton <lkcl@samba.org> | 1999-12-01 02:15:14 +0000 |
commit | 6ddfc68e0496dc41f8c9a022a0b04a2066b43c9d (patch) | |
tree | 2f8a0996fe269f79e86d6336e4520d3278b442ed /source3/lib/util_array.c | |
parent | 7e42174792298c8815acd1ebf34c357aff0de7c3 (diff) | |
download | samba-6ddfc68e0496dc41f8c9a022a0b04a2066b43c9d.tar.gz samba-6ddfc68e0496dc41f8c9a022a0b04a2066b43c9d.tar.bz2 samba-6ddfc68e0496dc41f8c9a022a0b04a2066b43c9d.zip |
sys_select added one more argument (read, write selectors).
(This used to be commit e4d92ff9dfc51735e6932748f66a7c20b2c1cb6a)
Diffstat (limited to 'source3/lib/util_array.c')
-rw-r--r-- | source3/lib/util_array.c | 71 |
1 files changed, 67 insertions, 4 deletions
diff --git a/source3/lib/util_array.c b/source3/lib/util_array.c index 62be3f17bd..71cd19e65d 100644 --- a/source3/lib/util_array.c +++ b/source3/lib/util_array.c @@ -77,6 +77,69 @@ void* add_item_to_array(uint32 *len, void ***array, void *item) return NULL; } +static void use_info_free(struct use_info *item) +{ + if (item != NULL) + { + if (item->srv_name != NULL) + { + free(item->srv_name); + } + if (item->user_name != NULL) + { + free(item->user_name); + } + if (item->domain != NULL) + { + free(item->domain); + } + free(item); + } +} + +static struct use_info *use_info_dup(const struct use_info *from) +{ + if (from != NULL) + { + struct use_info *copy = (struct use_info *) + malloc(sizeof(struct use_info)); + if (copy != NULL) + { + ZERO_STRUCTP(copy); + copy->connected = from->connected; + if (from->srv_name != NULL) + { + copy->srv_name = strdup(from->srv_name ); + } + if (from->user_name != NULL) + { + copy->user_name = strdup(from->user_name); + } + if (from->domain != NULL) + { + copy->domain = strdup(from->domain ); + } + } + return copy; + } + return NULL; +} + +void free_use_array(uint32 num_entries, struct use_info **entries) +{ + void(*fn)(void*) = (void(*)(void*))&use_info_free; + free_void_array(num_entries, (void**)entries, *fn); +} + +struct use_info* add_use_to_array(uint32 *len, struct use_info ***array, + const struct use_info *name) +{ + void*(*fn)(const void*) = (void*(*)(const void*))&use_info_dup; + return (struct use_info*)add_copy_to_array(len, + (void***)array, (const void*)name, *fn, False); + +} + void free_char_array(uint32 num_entries, char **entries) { void(*fn)(void*) = (void(*)(void*))&free; @@ -175,7 +238,7 @@ static PRINTER_INFO_2 *prt2_dup(const PRINTER_INFO_2* from) } else { - memset(copy, 0, sizeof(*copy)); + ZERO_STRUCTP(copy); } } return copy; @@ -206,7 +269,7 @@ static PRINTER_INFO_1 *prt1_dup(const PRINTER_INFO_1* from) } else { - memset(copy, 0, sizeof(*copy)); + ZERO_STRUCTP(copy); } } return copy; @@ -237,7 +300,7 @@ static JOB_INFO_1 *job1_dup(const JOB_INFO_1* from) } else { - memset(copy, 0, sizeof(*copy)); + ZERO_STRUCTP(copy); } } return copy; @@ -268,7 +331,7 @@ static JOB_INFO_2 *job2_dup(const JOB_INFO_2* from) } else { - memset(copy, 0, sizeof(*copy)); + ZERO_STRUCTP(copy); } } return copy; |