{
const char **list = NULL;
struct tevent_ops_list *e;
+ size_t idx = 0;
tevent_backend_init();
for (e=tevent_backends;e;e=e->next) {
- list = ev_str_list_add(list, e->name);
+ idx += 1;
}
- talloc_steal(mem_ctx, list);
+ list = talloc_zero_array(mem_ctx, const char *, idx+1);
+ if (list == NULL) {
+ return NULL;
+ }
+
+ idx = 0;
+ for (e=tevent_backends;e;e=e->next) {
+ list[idx] = talloc_strdup(list, e->name);
+ if (list[idx] == NULL) {
+ TALLOC_FREE(list);
+ return NULL;
+ }
+ idx += 1;
+ }
return list;
}
#include "tevent_util.h"
#include <fcntl.h>
-/**
- return the number of elements in a string list
-*/
-size_t ev_str_list_length(const char **list)
-{
- size_t ret;
- for (ret=0;list && list[ret];ret++) /* noop */ ;
- return ret;
-}
-
-/**
- add an entry to a string list
-*/
-const char **ev_str_list_add(const char **list, const char *s)
-{
- size_t len = ev_str_list_length(list);
- const char **ret;
-
- ret = talloc_realloc(NULL, list, const char *, len+2);
- if (ret == NULL) return NULL;
-
- ret[len] = talloc_strdup(ret, s);
- if (ret[len] == NULL) return NULL;
-
- ret[len+1] = NULL;
-
- return ret;
-}
-
-
/**
Set a fd into blocking/nonblocking mode. Uses POSIX O_NONBLOCK if available,
else
#endif /* _DLINKLIST_H */
-const char **ev_str_list_add(const char **list, const char *s);
int ev_set_blocking(int fd, bool set);
-size_t ev_str_list_length(const char **list);
bool ev_set_close_on_exec(int fd);
/* Defined here so we can build against older talloc versions that don't