sizeof(char) is 1. By definition.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73407 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -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() )
|
||||
{
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
|
@@ -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';
|
||||
}
|
||||
|
||||
|
@@ -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 );
|
||||
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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;
|
||||
|
@@ -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);
|
||||
|
@@ -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 );
|
||||
|
@@ -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 );
|
||||
|
||||
|
@@ -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 );
|
||||
|
||||
|
@@ -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() ;
|
||||
|
@@ -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,
|
||||
|
@@ -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 );
|
||||
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user