diff options
author | George Hazan <george.hazan@gmail.com> | 2014-01-03 15:57:52 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-01-03 15:57:52 +0000 |
commit | 5e0c012d677635e13cbfcf6730f2deafdc38c025 (patch) | |
tree | c6cd34a70ae0402f69faf5d65e974014b5e63fda /plugins/Variables/src/parse_inet.cpp | |
parent | cd4e43a5af4dcf660969bc5abada0d97cfd0cd03 (diff) |
- memory leak fixes
- code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@7479 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Variables/src/parse_inet.cpp')
-rw-r--r-- | plugins/Variables/src/parse_inet.cpp | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/plugins/Variables/src/parse_inet.cpp b/plugins/Variables/src/parse_inet.cpp index dfa92ba7f1..126642eddf 100644 --- a/plugins/Variables/src/parse_inet.cpp +++ b/plugins/Variables/src/parse_inet.cpp @@ -2,7 +2,7 @@ Variables Plugin for Miranda-IM (www.miranda-im.org)
Copyright 2003-2006 P. Boon
- This program is mir_free software; you can redistribute it and/or modify
+ This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
@@ -30,19 +30,19 @@ static TCHAR *parseUrlEnc(ARGUMENTSINFO *ai) size_t cur = 0;
while (cur < strlen(res)) {
- if (( (*(res+cur) >= '0') && (*(res+cur) <= '9')) || ( (*(res+cur) >= 'a') && (*(res+cur) <= 'z')) || ( (*(res+cur) >= 'A') && (*(res+cur) <= 'Z')) ) {
+ if (((*(res + cur) >= '0') && (*(res + cur) <= '9')) || ((*(res + cur) >= 'a') && (*(res + cur) <= 'z')) || ((*(res + cur) >= 'A') && (*(res + cur) <= 'Z'))) {
cur++;
continue;
}
- res = ( char* )mir_realloc(res, strlen(res)+4);
+ res = (char*)mir_realloc(res, strlen(res) + 4);
if (res == NULL)
return NULL;
char hex[8];
- MoveMemory(res+cur+3, res+cur+1, strlen(res+cur+1)+1);
- mir_snprintf(hex, sizeof(hex), "%%%x", *(res+cur));
- strncpy(res+cur, hex, strlen(hex));
- cur+=strlen(hex);
+ MoveMemory(res + cur + 3, res + cur + 1, strlen(res + cur + 1) + 1);
+ mir_snprintf(hex, sizeof(hex), "%%%x", *(res + cur));
+ strncpy(res + cur, hex, strlen(hex));
+ cur += strlen(hex);
}
TCHAR *tres = mir_a2t(res);
@@ -61,17 +61,17 @@ static TCHAR *parseUrlDec(ARGUMENTSINFO *ai) unsigned int cur = 0;
while (cur < strlen(res)) {
- if ((*(res+cur) == '%') && (strlen(res+cur) >= 3)) {
+ if ((*(res + cur) == '%') && (strlen(res + cur) >= 3)) {
char hex[8];
memset(hex, '\0', sizeof(hex));
- strncpy(hex, res+cur+1, 2);
- *(res+cur) = (char)strtol(hex, NULL, 16);
- MoveMemory(res+cur+1, res+cur+3, strlen(res+cur+3)+1);
+ strncpy(hex, res + cur + 1, 2);
+ *(res + cur) = (char)strtol(hex, NULL, 16);
+ MoveMemory(res + cur + 1, res + cur + 3, strlen(res + cur + 3) + 1);
}
cur++;
}
- res = ( char* )mir_realloc(res, strlen(res)+1);
+ res = (char*)mir_realloc(res, strlen(res) + 1);
TCHAR *tres = mir_a2t(res);
mir_free(res);
return tres;
@@ -81,20 +81,20 @@ static TCHAR *parseNToA(ARGUMENTSINFO *ai) {
if (ai->argc != 2)
return NULL;
-
+
struct in_addr in;
in.s_addr = ttoi(ai->targv[1]);
- return mir_a2t( inet_ntoa(in));
+ return mir_a2t(inet_ntoa(in));
}
static TCHAR *parseHToA(ARGUMENTSINFO *ai)
{
if (ai->argc != 2)
return NULL;
-
+
struct in_addr in;
in.s_addr = htonl(ttoi(ai->targv[1]));
- return mir_a2t( inet_ntoa(in));
+ return mir_a2t(inet_ntoa(in));
}
int registerInetTokens()
@@ -103,5 +103,5 @@ int registerInetTokens() registerIntToken(_T(URLDEC), parseUrlDec, TRF_FUNCTION, LPGEN("Internet Related")"\t(x)\t"LPGEN("converts each hex value into non-html character"));
registerIntToken(_T(NTOA), parseNToA, TRF_FUNCTION, LPGEN("Internet Related")"\t(x)\t"LPGEN("converts a 32-bit number to IPv4 dotted notation"));
registerIntToken(_T(HTOA), parseHToA, TRF_FUNCTION, LPGEN("Internet Related")"\t(x)\t"LPGEN("converts a 32-bit number (in host byte order) to IPv4 dotted notation"));
- return 0;
+ return 0;
}
|