From 784d9056f4f91e8c0eb4261456ab016214e22e17 Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Sun, 20 Jan 2013 03:08:33 +0000 Subject: [PATCH] sizeof(char) is 1. By definition. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73407 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/ffile.cpp | 2 +- src/common/imagpng.cpp | 2 +- src/common/wxcrt.cpp | 4 ++-- src/html/htmlctrl/webkit/webkit.mm | 2 +- src/msw/dde.cpp | 4 ++-- src/msw/metafile.cpp | 12 ++++++------ src/msw/ole/dataobj.cpp | 8 ++++---- src/osx/carbon/control.cpp | 2 +- src/osx/carbon/nonownedwnd.cpp | 2 +- src/osx/carbon/window.cpp | 2 +- src/osx/core/bitmap.cpp | 6 +++--- src/osx/webview_webkit.mm | 2 +- src/osx/window_osx.cpp | 2 +- src/unix/stdpaths.cpp | 2 +- 14 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/common/ffile.cpp b/src/common/ffile.cpp index 1d55267348..932498efcd 100644 --- a/src/common/ffile.cpp +++ b/src/common/ffile.cpp @@ -107,7 +107,7 @@ bool wxFFile::ReadAll(wxString *str, const wxMBConv& conv) // note that real length may be less than file length for text files with DOS EOLs // ('\r's get dropped by CRT when reading which means that we have // realLen = fileLen - numOfLinesInTheFile) - length = fread(buf.data(), sizeof(char), length, m_fp); + length = fread(buf.data(), 1, length, m_fp); if ( Error() ) { diff --git a/src/common/imagpng.cpp b/src/common/imagpng.cpp index 7fee6adbdb..81c411619b 100644 --- a/src/common/imagpng.cpp +++ b/src/common/imagpng.cpp @@ -567,7 +567,7 @@ wxPNGHandler::LoadFile(wxImage *image, for (i = 0; i < height; i++) { - if ((lines[i] = (unsigned char *)malloc( (size_t)(width * (sizeof(unsigned char) * 4)))) == NULL) + if ((lines[i] = (unsigned char *)malloc( (size_t)(width * 4))) == NULL) goto error; } diff --git a/src/common/wxcrt.cpp b/src/common/wxcrt.cpp index 5e8304da52..b9f4ef3c07 100644 --- a/src/common/wxcrt.cpp +++ b/src/common/wxcrt.cpp @@ -584,11 +584,11 @@ int ConvertStringToBuf(const wxString& s, char *out, size_t outsize) const size_t len = buf.length(); if ( outsize > len ) { - memcpy(out, buf, (len+1) * sizeof(char)); + memcpy(out, buf, len+1); } else // not enough space { - memcpy(out, buf, (outsize-1) * sizeof(char)); + memcpy(out, buf, outsize-1); out[outsize-1] = '\0'; } diff --git a/src/html/htmlctrl/webkit/webkit.mm b/src/html/htmlctrl/webkit/webkit.mm index f3944da585..c11a57960e 100644 --- a/src/html/htmlctrl/webkit/webkit.mm +++ b/src/html/htmlctrl/webkit/webkit.mm @@ -127,7 +127,7 @@ static pascal OSStatus wxWebKitKeyEventHandler( EventHandlerCallRef handler , Ev } #endif - GetEventParameter( event, kEventParamKeyMacCharCodes, typeChar, NULL, sizeof(char), NULL, &charCode ); + GetEventParameter( event, kEventParamKeyMacCharCodes, typeChar, NULL, 1, NULL, &charCode ); GetEventParameter( event, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode ); GetEventParameter( event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers ); diff --git a/src/msw/dde.cpp b/src/msw/dde.cpp index ce2f37211b..e2f7ae6f82 100644 --- a/src/msw/dde.cpp +++ b/src/msw/dde.cpp @@ -580,7 +580,7 @@ wxDDEConnection::DoExecute(const void *data, size_t size, wxIPCFormat format) if ( conv ) { const char * const text = (const char *)data; - const size_t len = size/sizeof(char); + const size_t len = size; realSize = conv->ToWChar(NULL, 0, text, len); if ( realSize == wxCONV_FAILED ) @@ -627,7 +627,7 @@ wxDDEConnection::DoExecute(const void *data, size_t size, wxIPCFormat format) if ( realSize == wxCONV_FAILED ) return false; - realData = (LPBYTE)buffer.GetWriteBuf(realSize*sizeof(char)); + realData = (LPBYTE)buffer.GetWriteBuf(realSize); if ( !realData ) return false; diff --git a/src/msw/metafile.cpp b/src/msw/metafile.cpp index 06f9a2a68f..3cbb79fb63 100644 --- a/src/msw/metafile.cpp +++ b/src/msw/metafile.cpp @@ -400,7 +400,7 @@ bool wxMakeMetafilePlaceable(const wxString& filename, int x1, int y1, int x2, i FILE *fHandle = wxFopen(tempFileBuf.fn_str(), wxT("wb")); if (!fHandle) return false; - fwrite((void *)&header, sizeof(unsigned char), sizeof(mfPLACEABLEHEADER), fHandle); + fwrite((void *)&header, 1, sizeof(mfPLACEABLEHEADER), fHandle); // Calculate origin and extent int originX = x1; @@ -410,14 +410,14 @@ bool wxMakeMetafilePlaceable(const wxString& filename, int x1, int y1, int x2, i // Read metafile header and write METAHEADER metaHeader; - fread((void *)&metaHeader, sizeof(unsigned char), sizeof(metaHeader), fd); + fread((void *)&metaHeader, 1, sizeof(metaHeader), fd); if (useOriginAndExtent) metaHeader.mtSize += 15; else metaHeader.mtSize += 5; - fwrite((void *)&metaHeader, sizeof(unsigned char), sizeof(metaHeader), fHandle); + fwrite((void *)&metaHeader, 1, sizeof(metaHeader), fHandle); // Write SetMapMode, SetWindowOrigin and SetWindowExt records char modeBuffer[8]; @@ -442,12 +442,12 @@ bool wxMakeMetafilePlaceable(const wxString& filename, int x1, int y1, int x2, i extentRecord->rdParm[0] = extentY; extentRecord->rdParm[1] = extentX; - fwrite((void *)modeBuffer, sizeof(char), 8, fHandle); + fwrite((void *)modeBuffer, 1, 8, fHandle); if (useOriginAndExtent) { - fwrite((void *)originBuffer, sizeof(char), 10, fHandle); - fwrite((void *)extentBuffer, sizeof(char), 10, fHandle); + fwrite((void *)originBuffer, 1, 10, fHandle); + fwrite((void *)extentBuffer, 1, 10, fHandle); } int ch = -2; diff --git a/src/msw/ole/dataobj.cpp b/src/msw/ole/dataobj.cpp index c479a2c9ab..a523c1c6e7 100644 --- a/src/msw/ole/dataobj.cpp +++ b/src/msw/ole/dataobj.cpp @@ -1306,7 +1306,7 @@ size_t wxFileDataObject::GetDataSize() const if ( wxGetOsVersion() == wxOS_WINDOWS_9X ) { // Win9x always uses ANSI file names and MSLU doesn't help with this - sizeOfChar = sizeof(char); + sizeOfChar = 1; } else { @@ -1325,7 +1325,7 @@ size_t wxFileDataObject::GetDataSize() const // add filename length plus null byte size_t len; #if wxUSE_UNICODE_MSLU - if ( sizeOfChar == sizeof(char) ) + if ( sizeOfChar == 1 ) len = strlen(m_filenames[i].mb_str(*wxConvFileName)); else #endif // wxUSE_UNICODE_MSLU @@ -1362,7 +1362,7 @@ bool wxFileDataObject::GetDataHere(void *WXUNUSED_IN_WINCE(pData)) const pDrop->fWide = wxUSE_UNICODE; #endif - const size_t sizeOfChar = pDrop->fWide ? sizeof(wchar_t) : sizeof(char); + const size_t sizeOfChar = pDrop->fWide ? sizeof(wchar_t) : 1; // set start of filenames list (null separated) BYTE *pbuf = (BYTE *)(pDrop + 1); @@ -1373,7 +1373,7 @@ bool wxFileDataObject::GetDataHere(void *WXUNUSED_IN_WINCE(pData)) const // copy filename to pbuf and add null terminator size_t len; #if wxUSE_UNICODE_MSLU - if ( sizeOfChar == sizeof(char) ) + if ( sizeOfChar == 1 ) { wxCharBuffer buf(m_filenames[i].mb_str(*wxConvFileName)); len = strlen(buf); diff --git a/src/osx/carbon/control.cpp b/src/osx/carbon/control.cpp index dba7a99689..eff5294e5b 100644 --- a/src/osx/carbon/control.cpp +++ b/src/osx/carbon/control.cpp @@ -81,7 +81,7 @@ void wxControl::OnKeyDown( wxKeyEvent &WXUNUSED(event) ) char charCode; GetEventParameter( (EventRef)wxTheApp->MacGetCurrentEvent(), kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode ); - GetEventParameter( (EventRef)wxTheApp->MacGetCurrentEvent(), kEventParamKeyMacCharCodes, typeChar, NULL, sizeof(char), NULL, &charCode ); + GetEventParameter( (EventRef)wxTheApp->MacGetCurrentEvent(), kEventParamKeyMacCharCodes, typeChar, NULL, 1, NULL, &charCode ); GetEventParameter( (EventRef)wxTheApp->MacGetCurrentEvent(), kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers ); GetPeer()->HandleKey( keyCode, charCode, modifiers ); diff --git a/src/osx/carbon/nonownedwnd.cpp b/src/osx/carbon/nonownedwnd.cpp index 8c70d538d7..45344b01a6 100644 --- a/src/osx/carbon/nonownedwnd.cpp +++ b/src/osx/carbon/nonownedwnd.cpp @@ -330,7 +330,7 @@ static pascal OSStatus KeyboardEventHandler( EventHandlerCallRef handler , Event } #endif // wxUSE_UNICODE - GetEventParameter( event, kEventParamKeyMacCharCodes, typeChar, NULL, sizeof(char), NULL, &charCode ); + GetEventParameter( event, kEventParamKeyMacCharCodes, typeChar, NULL, 1, NULL, &charCode ); GetEventParameter( event, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode ); GetEventParameter( event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers ); diff --git a/src/osx/carbon/window.cpp b/src/osx/carbon/window.cpp index 94c95ef5cf..48ae71bbfb 100644 --- a/src/osx/carbon/window.cpp +++ b/src/osx/carbon/window.cpp @@ -669,7 +669,7 @@ WXDLLEXPORT pascal OSStatus wxMacUnicodeTextEventHandler( EventHandlerCallRef ha unsigned char charCode ; GetEventParameter( event, kEventParamTextInputSendKeyboardEvent, typeEventRef, NULL, sizeof(rawEvent), NULL, &rawEvent ) ; - GetEventParameter( rawEvent, kEventParamKeyMacCharCodes, typeChar, NULL, sizeof(char), NULL, &charCode ); + GetEventParameter( rawEvent, kEventParamKeyMacCharCodes, typeChar, NULL, 1, NULL, &charCode ); GetEventParameter( rawEvent, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode ); GetEventParameter( rawEvent, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers ); diff --git a/src/osx/core/bitmap.cpp b/src/osx/core/bitmap.cpp index fcc3a24ac0..0003cb5a47 100644 --- a/src/osx/core/bitmap.cpp +++ b/src/osx/core/bitmap.cpp @@ -890,9 +890,9 @@ wxBitmap::wxBitmap(const char bits[], int the_width, int the_height, int no_bits { if ( no_bits == 1 ) { - int linesize = ( the_width / (sizeof(unsigned char) * 8)) ; - if ( the_width % (sizeof(unsigned char) * 8) ) - linesize += sizeof(unsigned char); + int linesize = the_width / 8; + if ( the_width % 8 ) + linesize++; unsigned char* linestart = (unsigned char*) bits ; unsigned char* destptr = (unsigned char*) BeginRawAccess() ; diff --git a/src/osx/webview_webkit.mm b/src/osx/webview_webkit.mm index 83b1946c89..241a5f97d2 100644 --- a/src/osx/webview_webkit.mm +++ b/src/osx/webview_webkit.mm @@ -134,7 +134,7 @@ static pascal OSStatus wxWebKitKeyEventHandler(EventHandlerCallRef handler, #endif GetEventParameter(event, kEventParamKeyMacCharCodes, typeChar, NULL, - sizeof(char), NULL, &charCode ); + 1, NULL, &charCode ); GetEventParameter(event, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode ); GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, NULL, diff --git a/src/osx/window_osx.cpp b/src/osx/window_osx.cpp index 465c1036f9..7fd9f067d9 100644 --- a/src/osx/window_osx.cpp +++ b/src/osx/window_osx.cpp @@ -2621,7 +2621,7 @@ wxHotKeyHandler(EventHandlerCallRef WXUNUSED(nextHandler), UInt32 modifiers ; UInt32 when = EventTimeToTicks( GetEventTime( event ) ) ; - GetEventParameter( event, kEventParamKeyMacCharCodes, typeChar, NULL, sizeof(char), NULL, &charCode ); + GetEventParameter( event, kEventParamKeyMacCharCodes, typeChar, NULL, 1, NULL, &charCode ); GetEventParameter( event, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode ); GetEventParameter( event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers ); diff --git a/src/unix/stdpaths.cpp b/src/unix/stdpaths.cpp index d65bb8dd7f..58f8c2c670 100644 --- a/src/unix/stdpaths.cpp +++ b/src/unix/stdpaths.cpp @@ -122,7 +122,7 @@ wxString wxStandardPaths::GetExecutablePath() const wxString exeStr; char buf[4096]; - int result = readlink("/proc/self/exe", buf, WXSIZEOF(buf) - sizeof(char)); + int result = readlink("/proc/self/exe", buf, WXSIZEOF(buf) - 1); if ( result != -1 ) { buf[result] = '\0'; // readlink() doesn't NUL-terminate the buffer -- 2.45.2