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;
|
||||
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);
|
||||
std::string retval(buffer);
|
||||
|
@ -187,7 +187,8 @@ std::string TelldusCore::wideToString(const std::wstring &input) {
|
|||
|
||||
#else
|
||||
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
|
||||
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
|
||||
char *outString = new char[outbytesLeft];
|
||||
memset(outString, 0, sizeof(char)*(outbytesLeft));
|
||||
memset(outString, 0, sizeof(*outString)*(outbytesLeft));
|
||||
|
||||
#ifdef _FREEBSD
|
||||
const char *inPointer = inString;
|
||||
|
|
|
@ -69,7 +69,8 @@ inline char *wrapStdString( const std::string &string) {
|
|||
#ifdef _WINDOWS
|
||||
return (char *)SysAllocStringByteLen(string.c_str(), (unsigned int)string.size());
|
||||
#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());
|
||||
return returnVal;
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue