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
|
// 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
|
// ('\r's get dropped by CRT when reading which means that we have
|
||||||
// realLen = fileLen - numOfLinesInTheFile)
|
// realLen = fileLen - numOfLinesInTheFile)
|
||||||
length = fread(buf.data(), sizeof(char), length, m_fp);
|
length = fread(buf.data(), 1, length, m_fp);
|
||||||
|
|
||||||
if ( Error() )
|
if ( Error() )
|
||||||
{
|
{
|
||||||
|
@@ -567,7 +567,7 @@ wxPNGHandler::LoadFile(wxImage *image,
|
|||||||
|
|
||||||
for (i = 0; i < height; i++)
|
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;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -584,11 +584,11 @@ int ConvertStringToBuf(const wxString& s, char *out, size_t outsize)
|
|||||||
const size_t len = buf.length();
|
const size_t len = buf.length();
|
||||||
if ( outsize > len )
|
if ( outsize > len )
|
||||||
{
|
{
|
||||||
memcpy(out, buf, (len+1) * sizeof(char));
|
memcpy(out, buf, len+1);
|
||||||
}
|
}
|
||||||
else // not enough space
|
else // not enough space
|
||||||
{
|
{
|
||||||
memcpy(out, buf, (outsize-1) * sizeof(char));
|
memcpy(out, buf, outsize-1);
|
||||||
out[outsize-1] = '\0';
|
out[outsize-1] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -127,7 +127,7 @@ static pascal OSStatus wxWebKitKeyEventHandler( EventHandlerCallRef handler , Ev
|
|||||||
}
|
}
|
||||||
#endif
|
#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, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode );
|
||||||
GetEventParameter( event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers );
|
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 )
|
if ( conv )
|
||||||
{
|
{
|
||||||
const char * const text = (const char *)data;
|
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);
|
realSize = conv->ToWChar(NULL, 0, text, len);
|
||||||
if ( realSize == wxCONV_FAILED )
|
if ( realSize == wxCONV_FAILED )
|
||||||
@@ -627,7 +627,7 @@ wxDDEConnection::DoExecute(const void *data, size_t size, wxIPCFormat format)
|
|||||||
if ( realSize == wxCONV_FAILED )
|
if ( realSize == wxCONV_FAILED )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
realData = (LPBYTE)buffer.GetWriteBuf(realSize*sizeof(char));
|
realData = (LPBYTE)buffer.GetWriteBuf(realSize);
|
||||||
if ( !realData )
|
if ( !realData )
|
||||||
return false;
|
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"));
|
FILE *fHandle = wxFopen(tempFileBuf.fn_str(), wxT("wb"));
|
||||||
if (!fHandle)
|
if (!fHandle)
|
||||||
return false;
|
return false;
|
||||||
fwrite((void *)&header, sizeof(unsigned char), sizeof(mfPLACEABLEHEADER), fHandle);
|
fwrite((void *)&header, 1, sizeof(mfPLACEABLEHEADER), fHandle);
|
||||||
|
|
||||||
// Calculate origin and extent
|
// Calculate origin and extent
|
||||||
int originX = x1;
|
int originX = x1;
|
||||||
@@ -410,14 +410,14 @@ bool wxMakeMetafilePlaceable(const wxString& filename, int x1, int y1, int x2, i
|
|||||||
|
|
||||||
// Read metafile header and write
|
// Read metafile header and write
|
||||||
METAHEADER metaHeader;
|
METAHEADER metaHeader;
|
||||||
fread((void *)&metaHeader, sizeof(unsigned char), sizeof(metaHeader), fd);
|
fread((void *)&metaHeader, 1, sizeof(metaHeader), fd);
|
||||||
|
|
||||||
if (useOriginAndExtent)
|
if (useOriginAndExtent)
|
||||||
metaHeader.mtSize += 15;
|
metaHeader.mtSize += 15;
|
||||||
else
|
else
|
||||||
metaHeader.mtSize += 5;
|
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
|
// Write SetMapMode, SetWindowOrigin and SetWindowExt records
|
||||||
char modeBuffer[8];
|
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[0] = extentY;
|
||||||
extentRecord->rdParm[1] = extentX;
|
extentRecord->rdParm[1] = extentX;
|
||||||
|
|
||||||
fwrite((void *)modeBuffer, sizeof(char), 8, fHandle);
|
fwrite((void *)modeBuffer, 1, 8, fHandle);
|
||||||
|
|
||||||
if (useOriginAndExtent)
|
if (useOriginAndExtent)
|
||||||
{
|
{
|
||||||
fwrite((void *)originBuffer, sizeof(char), 10, fHandle);
|
fwrite((void *)originBuffer, 1, 10, fHandle);
|
||||||
fwrite((void *)extentBuffer, sizeof(char), 10, fHandle);
|
fwrite((void *)extentBuffer, 1, 10, fHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ch = -2;
|
int ch = -2;
|
||||||
|
@@ -1306,7 +1306,7 @@ size_t wxFileDataObject::GetDataSize() const
|
|||||||
if ( wxGetOsVersion() == wxOS_WINDOWS_9X )
|
if ( wxGetOsVersion() == wxOS_WINDOWS_9X )
|
||||||
{
|
{
|
||||||
// Win9x always uses ANSI file names and MSLU doesn't help with this
|
// Win9x always uses ANSI file names and MSLU doesn't help with this
|
||||||
sizeOfChar = sizeof(char);
|
sizeOfChar = 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1325,7 +1325,7 @@ size_t wxFileDataObject::GetDataSize() const
|
|||||||
// add filename length plus null byte
|
// add filename length plus null byte
|
||||||
size_t len;
|
size_t len;
|
||||||
#if wxUSE_UNICODE_MSLU
|
#if wxUSE_UNICODE_MSLU
|
||||||
if ( sizeOfChar == sizeof(char) )
|
if ( sizeOfChar == 1 )
|
||||||
len = strlen(m_filenames[i].mb_str(*wxConvFileName));
|
len = strlen(m_filenames[i].mb_str(*wxConvFileName));
|
||||||
else
|
else
|
||||||
#endif // wxUSE_UNICODE_MSLU
|
#endif // wxUSE_UNICODE_MSLU
|
||||||
@@ -1362,7 +1362,7 @@ bool wxFileDataObject::GetDataHere(void *WXUNUSED_IN_WINCE(pData)) const
|
|||||||
pDrop->fWide = wxUSE_UNICODE;
|
pDrop->fWide = wxUSE_UNICODE;
|
||||||
#endif
|
#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)
|
// set start of filenames list (null separated)
|
||||||
BYTE *pbuf = (BYTE *)(pDrop + 1);
|
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
|
// copy filename to pbuf and add null terminator
|
||||||
size_t len;
|
size_t len;
|
||||||
#if wxUSE_UNICODE_MSLU
|
#if wxUSE_UNICODE_MSLU
|
||||||
if ( sizeOfChar == sizeof(char) )
|
if ( sizeOfChar == 1 )
|
||||||
{
|
{
|
||||||
wxCharBuffer buf(m_filenames[i].mb_str(*wxConvFileName));
|
wxCharBuffer buf(m_filenames[i].mb_str(*wxConvFileName));
|
||||||
len = strlen(buf);
|
len = strlen(buf);
|
||||||
|
@@ -81,7 +81,7 @@ void wxControl::OnKeyDown( wxKeyEvent &WXUNUSED(event) )
|
|||||||
char charCode;
|
char charCode;
|
||||||
|
|
||||||
GetEventParameter( (EventRef)wxTheApp->MacGetCurrentEvent(), kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode );
|
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 );
|
GetEventParameter( (EventRef)wxTheApp->MacGetCurrentEvent(), kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers );
|
||||||
|
|
||||||
GetPeer()->HandleKey( keyCode, charCode, modifiers );
|
GetPeer()->HandleKey( keyCode, charCode, modifiers );
|
||||||
|
@@ -330,7 +330,7 @@ static pascal OSStatus KeyboardEventHandler( EventHandlerCallRef handler , Event
|
|||||||
}
|
}
|
||||||
#endif // wxUSE_UNICODE
|
#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, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode );
|
||||||
GetEventParameter( event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers );
|
GetEventParameter( event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers );
|
||||||
|
|
||||||
|
@@ -669,7 +669,7 @@ WXDLLEXPORT pascal OSStatus wxMacUnicodeTextEventHandler( EventHandlerCallRef ha
|
|||||||
unsigned char charCode ;
|
unsigned char charCode ;
|
||||||
|
|
||||||
GetEventParameter( event, kEventParamTextInputSendKeyboardEvent, typeEventRef, NULL, sizeof(rawEvent), NULL, &rawEvent ) ;
|
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, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode );
|
||||||
GetEventParameter( rawEvent, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers );
|
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 )
|
if ( no_bits == 1 )
|
||||||
{
|
{
|
||||||
int linesize = ( the_width / (sizeof(unsigned char) * 8)) ;
|
int linesize = the_width / 8;
|
||||||
if ( the_width % (sizeof(unsigned char) * 8) )
|
if ( the_width % 8 )
|
||||||
linesize += sizeof(unsigned char);
|
linesize++;
|
||||||
|
|
||||||
unsigned char* linestart = (unsigned char*) bits ;
|
unsigned char* linestart = (unsigned char*) bits ;
|
||||||
unsigned char* destptr = (unsigned char*) BeginRawAccess() ;
|
unsigned char* destptr = (unsigned char*) BeginRawAccess() ;
|
||||||
|
@@ -134,7 +134,7 @@ static pascal OSStatus wxWebKitKeyEventHandler(EventHandlerCallRef handler,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
GetEventParameter(event, kEventParamKeyMacCharCodes, typeChar, NULL,
|
GetEventParameter(event, kEventParamKeyMacCharCodes, typeChar, NULL,
|
||||||
sizeof(char), NULL, &charCode );
|
1, NULL, &charCode );
|
||||||
GetEventParameter(event, kEventParamKeyCode, typeUInt32, NULL,
|
GetEventParameter(event, kEventParamKeyCode, typeUInt32, NULL,
|
||||||
sizeof(UInt32), NULL, &keyCode );
|
sizeof(UInt32), NULL, &keyCode );
|
||||||
GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, NULL,
|
GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, NULL,
|
||||||
|
@@ -2621,7 +2621,7 @@ wxHotKeyHandler(EventHandlerCallRef WXUNUSED(nextHandler),
|
|||||||
UInt32 modifiers ;
|
UInt32 modifiers ;
|
||||||
UInt32 when = EventTimeToTicks( GetEventTime( event ) ) ;
|
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, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode );
|
||||||
GetEventParameter( event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers );
|
GetEventParameter( event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers );
|
||||||
|
|
||||||
|
@@ -122,7 +122,7 @@ wxString wxStandardPaths::GetExecutablePath() const
|
|||||||
wxString exeStr;
|
wxString exeStr;
|
||||||
|
|
||||||
char buf[4096];
|
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 )
|
if ( result != -1 )
|
||||||
{
|
{
|
||||||
buf[result] = '\0'; // readlink() doesn't NUL-terminate the buffer
|
buf[result] = '\0'; // readlink() doesn't NUL-terminate the buffer
|
||||||
|
Reference in New Issue
Block a user