summaryrefslogtreecommitdiff
path: root/src/misc.c
diff options
context:
space:
mode:
authorAdam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864>2009-11-08 18:00:54 +0000
committerAdam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864>2009-11-08 18:00:54 +0000
commit1c1312624dfcdc9bbf4b7cb2c08b611411bfa7f6 (patch)
tree415c1959f9d090c0623056b2ee389c16a641c08b /src/misc.c
parent608b63d979fe8c33f8b79569405cc242c9bccd3d (diff)
Rewrote BuildStringList to use std::list instead of char**
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2632 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src/misc.c')
-rw-r--r--src/misc.c51
1 files changed, 30 insertions, 21 deletions
diff --git a/src/misc.c b/src/misc.c
index a84fc33d4..c0ab1954c 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -1031,6 +1031,36 @@ char *host_resolve(char *host)
/*************************************************************************/
+/** Build a string list from a source string
+ * @param src The source string
+ * @return a list of strings
+ */
+std::list<std::string> BuildStringList(const std::string &src)
+{
+ spacesepstream tokens(src);
+ std::string token;
+ std::list<std::string> Ret;
+
+ while (tokens.GetToken(token))
+ Ret.push_back(token);
+
+ return Ret;
+}
+
+std::list<ci::string> BuildStringList(const ci::string &src)
+{
+ spacesepstream tokens(src);
+ ci::string token;
+ std::list<ci::string> Ret;
+
+ while (tokens.GetToken(token))
+ Ret.push_back(token);
+
+ return Ret;
+}
+
+/*************************************************************************/
+
/**
* Change an unsigned string to a signed string, overwriting the original
* string.
@@ -1074,27 +1104,6 @@ void ntoa(struct in_addr addr, char *ipaddr, int len)
bytes[3]);
}
-/**
- * Build a string list from a given source string.
- * This is usually used for parsing out values from the config file, but could
- * be used for other things.
- **/
-char **buildStringList(const std::string &src, int *number)
-{
- int i = 0;
- char **list = NULL;
- spacesepstream tokens(src);
- std::string token;
-
- while (tokens.GetToken(token)) {
- i++;
- list = static_cast<char **>(realloc(list, sizeof(char *) * i));
- list[i - 1] = sstrdup(token.c_str());
- }
- *number = i; /* always zero it, even if we have no setters */
- return list;
-}
-
/*
* strlcat and strlcpy were ripped from openssh 2.5.1p2
* They had the following Copyright info: