Use sizeof(varname) instead of sizeof(type) according to Google style guidelines "runtime/sizeof"
This commit is contained in:
parent
1ac3fc25e0
commit
31ee1880ad
2 changed files with 6 additions and 4 deletions
|
@ -178,7 +178,7 @@ std::string TelldusCore::wideToString(const std::wstring &input) {
|
||||||
}
|
}
|
||||||
char *buffer;
|
char *buffer;
|
||||||
buffer = new char[size];
|
buffer = new char[size];
|
||||||
memset(buffer, 0, sizeof(char)*size);
|
memset(buffer, 0, sizeof(*buffer)*size);
|
||||||
|
|
||||||
int bytes = WideCharToMultiByte(CP_UTF8, 0, input.c_str(), -1, buffer, size, NULL, NULL);
|
int bytes = WideCharToMultiByte(CP_UTF8, 0, input.c_str(), -1, buffer, size, NULL, NULL);
|
||||||
std::string retval(buffer);
|
std::string retval(buffer);
|
||||||
|
@ -187,7 +187,8 @@ std::string TelldusCore::wideToString(const std::wstring &input) {
|
||||||
|
|
||||||
#else
|
#else
|
||||||
size_t wideSize = sizeof(wchar_t)*input.length();
|
size_t wideSize = sizeof(wchar_t)*input.length();
|
||||||
size_t outbytesLeft = wideSize+sizeof(char); // We cannot know how many wide character there is yet
|
// We cannot know how many wide character there is yet
|
||||||
|
size_t outbytesLeft = wideSize+sizeof(char); // NOLINT(runtime/sizeof)
|
||||||
|
|
||||||
// Copy the instring
|
// Copy the instring
|
||||||
char *inString = (char*)new wchar_t[input.length()+1];
|
char *inString = (char*)new wchar_t[input.length()+1];
|
||||||
|
@ -195,7 +196,7 @@ std::string TelldusCore::wideToString(const std::wstring &input) {
|
||||||
|
|
||||||
// Create buffer for output
|
// Create buffer for output
|
||||||
char *outString = new char[outbytesLeft];
|
char *outString = new char[outbytesLeft];
|
||||||
memset(outString, 0, sizeof(char)*(outbytesLeft));
|
memset(outString, 0, sizeof(*outString)*(outbytesLeft));
|
||||||
|
|
||||||
#ifdef _FREEBSD
|
#ifdef _FREEBSD
|
||||||
const char *inPointer = inString;
|
const char *inPointer = inString;
|
||||||
|
|
|
@ -69,7 +69,8 @@ inline char *wrapStdString( const std::string &string) {
|
||||||
#ifdef _WINDOWS
|
#ifdef _WINDOWS
|
||||||
return (char *)SysAllocStringByteLen(string.c_str(), (unsigned int)string.size());
|
return (char *)SysAllocStringByteLen(string.c_str(), (unsigned int)string.size());
|
||||||
#else
|
#else
|
||||||
char *returnVal = (char *)malloc(sizeof(char) * (string.size()+1));
|
char *returnVal;
|
||||||
|
returnVal = (char *)malloc(sizeof(*returnVal) * (string.size()+1));
|
||||||
strcpy(returnVal, string.c_str());
|
strcpy(returnVal, string.c_str());
|
||||||
return returnVal;
|
return returnVal;
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue