summaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/base64.cpp2
-rw-r--r--src/utils/processorutils.cpp2
-rw-r--r--src/utils/sha256.cpp4
-rw-r--r--src/utils/string.h2
-rw-r--r--src/utils/stringfilter.cpp4
-rw-r--r--src/utils/stringfilter.h4
-rw-r--r--src/utils/timer.cpp4
-rw-r--r--src/utils/tokencollector.cpp6
-rw-r--r--src/utils/tokencollector.h6
-rw-r--r--src/utils/xml.cpp4
10 files changed, 19 insertions, 19 deletions
diff --git a/src/utils/base64.cpp b/src/utils/base64.cpp
index 342c39b0..b89ee9e7 100644
--- a/src/utils/base64.cpp
+++ b/src/utils/base64.cpp
@@ -34,7 +34,7 @@ static char base64_pad = '=';
unsigned char *php_base64_encode(const unsigned char *str, int length, int *ret_length) {
const unsigned char *current = str;
int i = 0;
- unsigned char *result = (unsigned char *)malloc(((length + 3 - length % 3) * 4 / 3 + 1) * sizeof(char));
+ auto result = (unsigned char *)malloc(((length + 3 - length % 3) * 4 / 3 + 1) * sizeof(char));
while (length > 2) { /* keep going until we have less than 24 bits */
result[i++] = base64_table[current[0] >> 2];
diff --git a/src/utils/processorutils.cpp b/src/utils/processorutils.cpp
index 06ef0178..4b18bf00 100644
--- a/src/utils/processorutils.cpp
+++ b/src/utils/processorutils.cpp
@@ -30,6 +30,6 @@ void utils::processor::init()
bool utils::processor::littleEndianCheck()
{
short int word = 0x0001; // Store 0x0001 in a 16-bit int.
- char *byte = (char *) &word; // 'byte' points to the first byte in word.
+ auto byte = (char *) &word; // 'byte' points to the first byte in word.
return(byte[0]); // byte[0] will be 1 on little-endian processors.
}
diff --git a/src/utils/sha256.cpp b/src/utils/sha256.cpp
index 102171e9..f9ea3fa1 100644
--- a/src/utils/sha256.cpp
+++ b/src/utils/sha256.cpp
@@ -77,8 +77,8 @@
#ifdef HAVE_STDINT_H
#include <stdint.h>
#else
-typedef unsigned char uint8_t;
-typedef unsigned int uint32_t;
+using uint8_t = unsigned char;
+using uint32_t = unsigned int;
#endif
#define SHA256_BLOCK_SIZE (512 / 8)
diff --git a/src/utils/string.h b/src/utils/string.h
index 882b1b09..6dcd6fe4 100644
--- a/src/utils/string.h
+++ b/src/utils/string.h
@@ -121,7 +121,7 @@ namespace utils
}
private:
- typedef std::map<std::string, T> Map;
+ using Map = std::map<std::string, T>;
Map mMap;
const T mDefault;
diff --git a/src/utils/stringfilter.cpp b/src/utils/stringfilter.cpp
index e3696097..8c417ed0 100644
--- a/src/utils/stringfilter.cpp
+++ b/src/utils/stringfilter.cpp
@@ -60,7 +60,7 @@ void StringFilter::writeSlangFilterList()
{
// Write the list to config
std::string slangsList;
- for (SlangIterator i = mSlangs.begin(); i != mSlangs.end(); )
+ for (auto i = mSlangs.begin(); i != mSlangs.end(); )
{
slangsList += *i;
++i;
@@ -82,7 +82,7 @@ bool StringFilter::filterContent(const std::string &text) const
std::transform(text.begin(), text.end(), upperCaseText.begin(),
(int(*)(int))std::toupper);
- for (Slangs::const_iterator i = mSlangs.begin(); i != mSlangs.end(); ++i)
+ for (auto i = mSlangs.begin(); i != mSlangs.end(); ++i)
{
// We look for slangs into the sentence.
std::string upperCaseSlang = *i;
diff --git a/src/utils/stringfilter.h b/src/utils/stringfilter.h
index 1ccb5c72..2d5ba5ba 100644
--- a/src/utils/stringfilter.h
+++ b/src/utils/stringfilter.h
@@ -71,8 +71,8 @@ class StringFilter
bool findDoubleQuotes(const std::string &text) const;
private:
- typedef std::list<std::string> Slangs;
- typedef Slangs::iterator SlangIterator;
+ using Slangs = std::list<std::string>;
+ using SlangIterator = Slangs::iterator;
Slangs mSlangs; /**< the formatted Slangs list */
bool mInitialized; /**< Set if the list is loaded */
};
diff --git a/src/utils/timer.cpp b/src/utils/timer.cpp
index c01a4134..3d1e0e6d 100644
--- a/src/utils/timer.cpp
+++ b/src/utils/timer.cpp
@@ -35,7 +35,7 @@ static uint64_t getTimeInMillisec()
uint64_t timeInMillisec;
timeval time;
- gettimeofday(&time, 0);
+ gettimeofday(&time, nullptr);
timeInMillisec = (uint64_t)time.tv_sec * 1000 + time.tv_usec / 1000;
return timeInMillisec;
}
@@ -59,7 +59,7 @@ void Timer::sleep()
struct timespec req;
req.tv_sec = 0;
req.tv_nsec = (interval - (now - lastpulse)) * (1000 * 1000);
- nanosleep(&req, 0);
+ nanosleep(&req, nullptr);
#else
Sleep(interval - (now - lastpulse));
#endif
diff --git a/src/utils/tokencollector.cpp b/src/utils/tokencollector.cpp
index 691eca20..ecbae632 100644
--- a/src/utils/tokencollector.cpp
+++ b/src/utils/tokencollector.cpp
@@ -29,7 +29,7 @@
void TokenCollectorBase::insertClient(const std::string &token, intptr_t data)
{
- for (std::list<Item>::reverse_iterator it = mPendingConnects.rbegin(),
+ for (auto it = mPendingConnects.rbegin(),
it_end = mPendingConnects.rend(); it != it_end; ++it)
{
if (it->token == token)
@@ -53,7 +53,7 @@ void TokenCollectorBase::insertClient(const std::string &token, intptr_t data)
void TokenCollectorBase::insertConnect(const std::string &token, intptr_t data)
{
- for (std::list<Item>::reverse_iterator it = mPendingClients.rbegin(),
+ for (auto it = mPendingClients.rbegin(),
it_end = mPendingClients.rend(); it != it_end; ++it)
{
if (it->token == token)
@@ -77,7 +77,7 @@ void TokenCollectorBase::insertConnect(const std::string &token, intptr_t data)
void TokenCollectorBase::removeClient(intptr_t data)
{
- for (std::list<Item>::iterator it = mPendingClients.begin(),
+ for (auto it = mPendingClients.begin(),
it_end = mPendingClients.end(); it != it_end; ++it)
{
if (it->data == data)
diff --git a/src/utils/tokencollector.h b/src/utils/tokencollector.h
index 0923eac6..64977d26 100644
--- a/src/utils/tokencollector.h
+++ b/src/utils/tokencollector.h
@@ -124,13 +124,13 @@ class TokenCollector: private TokenCollectorBase
private:
- void removedClient(intptr_t data)
+ void removedClient(intptr_t data) override
{ mHandler->deletePendingClient((Client)data); }
- void removedConnect(intptr_t data)
+ void removedConnect(intptr_t data) override
{ mHandler->deletePendingConnect((ServerData)data); }
- void foundMatch(intptr_t client, intptr_t data)
+ void foundMatch(intptr_t client, intptr_t data) override
{ mHandler->tokenMatched((Client)client, (ServerData)data); }
Handler *mHandler;
diff --git a/src/utils/xml.cpp b/src/utils/xml.cpp
index 3c286db1..f1b27cbe 100644
--- a/src/utils/xml.cpp
+++ b/src/utils/xml.cpp
@@ -31,7 +31,7 @@
namespace XML
{
Document::Document(const std::string &fileName, bool useResman):
- mDoc(0)
+ mDoc(nullptr)
{
std::string resolvedFileName = fileName;
if (useResman)
@@ -63,7 +63,7 @@ namespace XML
xmlNodePtr Document::rootNode()
{
- return mDoc ? xmlDocGetRootElement(mDoc) : 0;
+ return mDoc ? xmlDocGetRootElement(mDoc) : nullptr;
}
bool hasProperty(xmlNodePtr node, const char *name)