mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-09 23:34:20 +00:00
Changed some types from int to size_t where appropriate. Fixed a CoreMidi build problem in 64-bit mode.
This commit is contained in:
parent
f507bb8a48
commit
bfd9350bed
46 changed files with 155 additions and 151 deletions
|
|
@ -30,11 +30,11 @@
|
|||
//==============================================================================
|
||||
namespace FileHelpers
|
||||
{
|
||||
static int64 calculateMemoryHashCode (const void* data, const int numBytes)
|
||||
static int64 calculateMemoryHashCode (const void* data, const size_t numBytes)
|
||||
{
|
||||
int64 t = 0;
|
||||
|
||||
for (int i = 0; i < numBytes; ++i)
|
||||
for (size_t i = 0; i < numBytes; ++i)
|
||||
t = t * 65599 + static_cast <const uint8*> (data)[i];
|
||||
|
||||
return t;
|
||||
|
|
@ -68,7 +68,7 @@ namespace FileHelpers
|
|||
return stream != nullptr ? calculateStreamHashCode (*stream) : 0;
|
||||
}
|
||||
|
||||
bool overwriteFileWithNewDataIfDifferent (const File& file, const void* data, int numBytes)
|
||||
bool overwriteFileWithNewDataIfDifferent (const File& file, const void* data, size_t numBytes)
|
||||
{
|
||||
if (file.getSize() == numBytes
|
||||
&& calculateMemoryHashCode (data, numBytes) == calculateFileHashCode (file))
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ public:
|
|||
// The send button has been pressed, so write out the contents of the
|
||||
// text box to the socket or pipe, depending on which is active.
|
||||
const String text (sendText.getText());
|
||||
MemoryBlock messageData (text.toUTF8(), (size_t) text.getNumBytesAsUTF8());
|
||||
MemoryBlock messageData (text.toUTF8(), text.getNumBytesAsUTF8());
|
||||
|
||||
for (int i = activeConnections.size(); --i >= 0;)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ void LagrangeInterpolator::reset() noexcept
|
|||
}
|
||||
|
||||
int LagrangeInterpolator::process (const double actualRatio, const float* in,
|
||||
float* out, const int numOut) noexcept
|
||||
float* out, const int numOut) noexcept
|
||||
{
|
||||
if (actualRatio == 1.0)
|
||||
{
|
||||
|
|
@ -132,7 +132,7 @@ int LagrangeInterpolator::process (const double actualRatio, const float* in,
|
|||
}
|
||||
|
||||
subSamplePos = pos;
|
||||
return in - originalIn;
|
||||
return (int) (in - originalIn);
|
||||
}
|
||||
|
||||
int LagrangeInterpolator::processAdding (const double actualRatio, const float* in,
|
||||
|
|
@ -197,5 +197,5 @@ int LagrangeInterpolator::processAdding (const double actualRatio, const float*
|
|||
}
|
||||
|
||||
subSamplePos = pos;
|
||||
return in - originalIn;
|
||||
return (int) (in - originalIn);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -408,7 +408,7 @@ void MidiFile::writeTrack (OutputStream& mainOut, const int trackNum)
|
|||
MidiFileHelpers::writeVariableLengthInt (out, (uint32) dataSize);
|
||||
}
|
||||
|
||||
out.write (data, dataSize);
|
||||
out.write (data, (size_t) dataSize);
|
||||
lastStatusByte = statusByte;
|
||||
}
|
||||
}
|
||||
|
|
@ -416,7 +416,7 @@ void MidiFile::writeTrack (OutputStream& mainOut, const int trackNum)
|
|||
{
|
||||
out.writeByte (0); // (tick delta)
|
||||
const MidiMessage m (MidiMessage::endOfTrack());
|
||||
out.write (m.getRawData(), m.getRawDataSize());
|
||||
out.write (m.getRawData(), (size_t) m.getRawDataSize());
|
||||
}
|
||||
|
||||
mainOut.writeIntBigEndian ((int) ByteOrder::bigEndianInt ("MTrk"));
|
||||
|
|
|
|||
|
|
@ -620,7 +620,7 @@ bool MidiMessage::isSysEx() const noexcept
|
|||
return *data == 0xf0;
|
||||
}
|
||||
|
||||
MidiMessage MidiMessage::createSysExMessage (const uint8* sysexData, const int dataSize)
|
||||
MidiMessage MidiMessage::createSysExMessage (const void* sysexData, const int dataSize)
|
||||
{
|
||||
HeapBlock<uint8> m ((size_t) dataSize + 2);
|
||||
|
||||
|
|
|
|||
|
|
@ -846,7 +846,7 @@ public:
|
|||
|
||||
The data passed in is wrapped with header and tail bytes of 0xf0 and 0xf7.
|
||||
*/
|
||||
static MidiMessage createSysExMessage (const uint8* sysexData,
|
||||
static MidiMessage createSysExMessage (const void* sysexData,
|
||||
int dataSize);
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -65,20 +65,20 @@ namespace CoreMidiHelpers
|
|||
{
|
||||
String result (getMidiObjectName (endpoint));
|
||||
|
||||
MIDIEntityRef entity = nullptr;
|
||||
MIDIEntityRef entity = 0; // NB: don't attempt to use nullptr for refs - it fails in some types of build.
|
||||
MIDIEndpointGetEntity (endpoint, &entity);
|
||||
|
||||
if (entity == nullptr)
|
||||
if (entity == 0)
|
||||
return result; // probably virtual
|
||||
|
||||
if (result.isEmpty())
|
||||
result = getMidiObjectName (entity); // endpoint name is empty - try the entity
|
||||
|
||||
// now consider the device's name
|
||||
MIDIDeviceRef device = nullptr;
|
||||
MIDIDeviceRef device = 0;
|
||||
MIDIEntityGetDevice (entity, &device);
|
||||
|
||||
if (device != nullptr)
|
||||
if (device != 0)
|
||||
{
|
||||
const String deviceName (getMidiObjectName (device));
|
||||
|
||||
|
|
@ -174,7 +174,7 @@ namespace CoreMidiHelpers
|
|||
: MIDIGetDestination (i);
|
||||
String name;
|
||||
|
||||
if (dest != nullptr)
|
||||
if (dest != 0)
|
||||
name = getConnectedEndpointName (dest);
|
||||
|
||||
if (name.isEmpty())
|
||||
|
|
@ -201,9 +201,9 @@ namespace CoreMidiHelpers
|
|||
|
||||
static MIDIClientRef getGlobalMidiClient()
|
||||
{
|
||||
static MIDIClientRef globalMidiClient = nullptr;
|
||||
static MIDIClientRef globalMidiClient = 0;
|
||||
|
||||
if (globalMidiClient == nullptr)
|
||||
if (globalMidiClient == 0)
|
||||
{
|
||||
// Since OSX 10.6, the MIDIClientCreate function will only work
|
||||
// correctly when called from the message thread!
|
||||
|
|
@ -228,16 +228,16 @@ namespace CoreMidiHelpers
|
|||
|
||||
~MidiPortAndEndpoint()
|
||||
{
|
||||
if (port != nullptr)
|
||||
if (port != 0)
|
||||
MIDIPortDispose (port);
|
||||
|
||||
if (port == nullptr && endPoint != nullptr) // if port == nullptr, it means we created the endpoint, so it's safe to delete it
|
||||
if (port == 0 && endPoint != 0) // if port == nullptr, it means we created the endpoint, so it's safe to delete it
|
||||
MIDIEndpointDispose (endPoint);
|
||||
}
|
||||
|
||||
void send (const MIDIPacketList* const packets)
|
||||
{
|
||||
if (port != nullptr)
|
||||
if (port != 0)
|
||||
MIDISend (port, endPoint, packets);
|
||||
else
|
||||
MIDIReceived (endPoint, packets);
|
||||
|
|
@ -269,7 +269,7 @@ namespace CoreMidiHelpers
|
|||
activeCallbacks.removeFirstMatchingValue (this);
|
||||
}
|
||||
|
||||
if (portAndEndpoint != nullptr && portAndEndpoint->port != nullptr)
|
||||
if (portAndEndpoint != 0 && portAndEndpoint->port != 0)
|
||||
CHECK_ERROR (MIDIPortDisconnectSource (portAndEndpoint->port, portAndEndpoint->endPoint));
|
||||
}
|
||||
|
||||
|
|
@ -325,7 +325,7 @@ MidiOutput* MidiOutput::openDevice (int index)
|
|||
MIDIClientRef client = CoreMidiHelpers::getGlobalMidiClient();
|
||||
MIDIPortRef port;
|
||||
|
||||
if (client != nullptr && CHECK_ERROR (MIDIOutputPortCreate (client, pname, &port)))
|
||||
if (client != 0 && CHECK_ERROR (MIDIOutputPortCreate (client, pname, &port)))
|
||||
{
|
||||
mo = new MidiOutput();
|
||||
mo->internal = new CoreMidiHelpers::MidiPortAndEndpoint (port, endPoint);
|
||||
|
|
@ -346,10 +346,10 @@ MidiOutput* MidiOutput::createNewDevice (const String& deviceName)
|
|||
MIDIEndpointRef endPoint;
|
||||
CFStringRef name = deviceName.toCFString();
|
||||
|
||||
if (client != nullptr && CHECK_ERROR (MIDISourceCreate (client, name, &endPoint)))
|
||||
if (client != 0 && CHECK_ERROR (MIDISourceCreate (client, name, &endPoint)))
|
||||
{
|
||||
mo = new MidiOutput();
|
||||
mo->internal = new CoreMidiHelpers::MidiPortAndEndpoint (nullptr, endPoint);
|
||||
mo->internal = new CoreMidiHelpers::MidiPortAndEndpoint (0, endPoint);
|
||||
}
|
||||
|
||||
CFRelease (name);
|
||||
|
|
@ -489,7 +489,7 @@ MidiInput* MidiInput::createNewDevice (const String& deviceName, MidiInputCallba
|
|||
|
||||
if (CHECK_ERROR (MIDIDestinationCreate (client, name, midiInputProc, mpc, &endPoint)))
|
||||
{
|
||||
mpc->portAndEndpoint = new MidiPortAndEndpoint (nullptr, endPoint);
|
||||
mpc->portAndEndpoint = new MidiPortAndEndpoint (0, endPoint);
|
||||
|
||||
mi = new MidiInput (deviceName);
|
||||
mpc->input = mi;
|
||||
|
|
|
|||
|
|
@ -1069,7 +1069,7 @@ bool AudioCDReader::readSamples (int** destSamples, int numDestChannels, int sta
|
|||
}
|
||||
else
|
||||
{
|
||||
const int framesInBuffer = buffer.getSize() / bytesPerFrame;
|
||||
const int framesInBuffer = (int) (buffer.getSize() / bytesPerFrame);
|
||||
const int frameNeeded = (int) (startSampleInFile / samplesPerFrame);
|
||||
|
||||
if (firstFrameInBuffer + framesInBuffer != frameNeeded)
|
||||
|
|
|
|||
|
|
@ -193,7 +193,7 @@ namespace AiffFileHelpers
|
|||
out.writeShortBigEndian ((short) identifier);
|
||||
out.writeIntBigEndian (offset);
|
||||
|
||||
const int labelLength = jmin (254, label.getNumBytesAsUTF8()); // seems to need null terminator even though it's a pstring
|
||||
const size_t labelLength = jmin ((size_t) 254, label.getNumBytesAsUTF8()); // seems to need null terminator even though it's a pstring
|
||||
out.writeByte ((char) labelLength + 1);
|
||||
out.write (label.toUTF8(), labelLength);
|
||||
out.writeByte (0);
|
||||
|
|
@ -226,7 +226,7 @@ namespace AiffFileHelpers
|
|||
|
||||
const String comment (values.getValue (prefix + "Text", String::empty));
|
||||
|
||||
const int commentLength = jmin (comment.getNumBytesAsUTF8(), 65534);
|
||||
const size_t commentLength = jmin (comment.getNumBytesAsUTF8(), (size_t) 65534);
|
||||
out.writeShortBigEndian ((short) commentLength + 1);
|
||||
out.write (comment.toUTF8(), commentLength);
|
||||
out.writeByte (0);
|
||||
|
|
@ -527,7 +527,7 @@ public:
|
|||
}
|
||||
|
||||
if (bytesWritten + bytes >= (size_t) 0xfff00000
|
||||
|| ! output->write (tempBlock.getData(), (int) bytes))
|
||||
|| ! output->write (tempBlock.getData(), bytes))
|
||||
{
|
||||
// failed to write to disk, so let's try writing the header.
|
||||
// If it's just run out of disk space, then if it does manage
|
||||
|
|
|
|||
|
|
@ -391,7 +391,7 @@ public:
|
|||
|
||||
bool writeData (const void* const data, const int size) const
|
||||
{
|
||||
return output->write (data, size);
|
||||
return output->write (data, (size_t) size);
|
||||
}
|
||||
|
||||
static void packUint32 (FlacNamespace::FLAC__uint32 val, FlacNamespace::FLAC__byte* b, const int bytes)
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ namespace WavFileHelpers
|
|||
|
||||
static MemoryBlock createFrom (const StringPairArray& values)
|
||||
{
|
||||
const size_t sizeNeeded = sizeof (BWAVChunk) + (size_t) values [WavAudioFormat::bwavCodingHistory].getNumBytesAsUTF8();
|
||||
const size_t sizeNeeded = sizeof (BWAVChunk) + values [WavAudioFormat::bwavCodingHistory].getNumBytesAsUTF8();
|
||||
MemoryBlock data ((sizeNeeded + 3) & ~3);
|
||||
data.fillWith (0);
|
||||
|
||||
|
|
@ -401,7 +401,7 @@ namespace WavFileHelpers
|
|||
const int chunkType, MemoryOutputStream& out)
|
||||
{
|
||||
const String label (values.getValue (prefix + "Text", prefix));
|
||||
const int labelLength = label.getNumBytesAsUTF8() + 1;
|
||||
const int labelLength = (int) label.getNumBytesAsUTF8() + 1;
|
||||
const int chunkLength = 4 + labelLength + (labelLength & 1);
|
||||
|
||||
out.writeInt (chunkType);
|
||||
|
|
@ -417,7 +417,7 @@ namespace WavFileHelpers
|
|||
{
|
||||
const String text (values.getValue (prefix + "Text", prefix));
|
||||
|
||||
const int textLength = text.getNumBytesAsUTF8() + 1; // include null terminator
|
||||
const int textLength = (int) text.getNumBytesAsUTF8() + 1; // include null terminator
|
||||
int chunkLength = textLength + 20 + (textLength & 1);
|
||||
|
||||
out.writeInt (chunkName ("ltxt"));
|
||||
|
|
@ -832,7 +832,7 @@ public:
|
|||
default: jassertfalse; break;
|
||||
}
|
||||
|
||||
if (! output->write (tempBlock.getData(), (int) bytes))
|
||||
if (! output->write (tempBlock.getData(), bytes))
|
||||
{
|
||||
// failed to write to disk, so let's try writing the header.
|
||||
// If it's just run out of disk space, then if it does manage
|
||||
|
|
|
|||
|
|
@ -848,7 +848,7 @@ private:
|
|||
// Pro-tools expects all your parameters to have valid names!
|
||||
jassert (juceFilter->getParameterName (index).isNotEmpty());
|
||||
|
||||
juceFilter->getParameterName (index).copyToUTF8 (name, maxLength);
|
||||
juceFilter->getParameterName (index).copyToUTF8 (name, (size_t) maxLength);
|
||||
}
|
||||
|
||||
long GetPriority() const { return kFicCooperativeTaskPriority; }
|
||||
|
|
@ -863,7 +863,7 @@ private:
|
|||
|
||||
void GetValueString (char* valueString, int maxLength, long value) const
|
||||
{
|
||||
juceFilter->getParameterText (index).copyToUTF8 (valueString, maxLength);
|
||||
juceFilter->getParameterText (index).copyToUTF8 (valueString, (size_t) maxLength);
|
||||
}
|
||||
|
||||
Cmn_Bool IsAutomatable() const
|
||||
|
|
|
|||
|
|
@ -436,8 +436,8 @@ public:
|
|||
static void setPinProperties (VstPinProperties& properties, const String& name,
|
||||
VstSpeakerArrangementType type, const bool isPair)
|
||||
{
|
||||
name.copyToUTF8 (properties.label, kVstMaxLabelLen - 1);
|
||||
name.copyToUTF8 (properties.shortLabel, kVstMaxShortLabelLen - 1);
|
||||
name.copyToUTF8 (properties.label, (size_t) (kVstMaxLabelLen - 1));
|
||||
name.copyToUTF8 (properties.shortLabel, (size_t) (kVstMaxShortLabelLen - 1));
|
||||
|
||||
if (type != kSpeakerArrEmpty)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1393,7 +1393,7 @@ public:
|
|||
if (JUCEApplication* app = JUCEApplication::getInstance())
|
||||
hostName = app->getApplicationName();
|
||||
|
||||
hostName.copyToUTF8 ((char*) ptr, jmin (kVstMaxVendorStrLen, kVstMaxProductStrLen) - 1);
|
||||
hostName.copyToUTF8 ((char*) ptr, (size_t) jmin (kVstMaxVendorStrLen, kVstMaxProductStrLen) - 1);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -236,15 +236,15 @@ const uint32 magicXmlNumber = 0x21324356;
|
|||
void AudioProcessor::copyXmlToBinary (const XmlElement& xml, juce::MemoryBlock& destData)
|
||||
{
|
||||
const String xmlString (xml.createDocument (String::empty, true, false));
|
||||
const int stringLength = xmlString.getNumBytesAsUTF8();
|
||||
const size_t stringLength = xmlString.getNumBytesAsUTF8();
|
||||
|
||||
destData.setSize ((size_t) stringLength + 9);
|
||||
destData.setSize (stringLength + 9);
|
||||
|
||||
char* const d = static_cast<char*> (destData.getData());
|
||||
*(uint32*) d = ByteOrder::swapIfBigEndian ((const uint32) magicXmlNumber);
|
||||
*(uint32*) (d + 4) = ByteOrder::swapIfBigEndian ((const uint32) stringLength);
|
||||
uint32* const d = static_cast<uint32*> (destData.getData());
|
||||
d[0] = ByteOrder::swapIfBigEndian ((const uint32) magicXmlNumber);
|
||||
d[1] = ByteOrder::swapIfBigEndian ((const uint32) stringLength);
|
||||
|
||||
xmlString.copyToUTF8 (d + 8, stringLength + 1);
|
||||
xmlString.copyToUTF8 ((CharPointer_UTF8::CharType*) (d + 2), stringLength + 1);
|
||||
}
|
||||
|
||||
XmlElement* AudioProcessor::getXmlFromBinary (const void* data, const int sizeInBytes)
|
||||
|
|
|
|||
|
|
@ -211,10 +211,10 @@ public:
|
|||
void writeToStream (const ValueUnion& data, OutputStream& output) const
|
||||
{
|
||||
const String* const s = getString (data);
|
||||
const int len = s->getNumBytesAsUTF8() + 1;
|
||||
HeapBlock<char> temp ((size_t) len);
|
||||
const size_t len = s->getNumBytesAsUTF8() + 1;
|
||||
HeapBlock<char> temp (len);
|
||||
s->copyToUTF8 (temp, len);
|
||||
output.writeCompressedInt (len + 1);
|
||||
output.writeCompressedInt ((int) (len + 1));
|
||||
output.writeByte (varMarker_String);
|
||||
output.write (temp, len);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -672,9 +672,11 @@ FileOutputStream* File::createOutputStream (const int bufferSize) const
|
|||
|
||||
//==============================================================================
|
||||
bool File::appendData (const void* const dataToAppend,
|
||||
const int numberOfBytes) const
|
||||
const size_t numberOfBytes) const
|
||||
{
|
||||
if (numberOfBytes <= 0)
|
||||
jassert (((ssize_t) numberOfBytes) >= 0);
|
||||
|
||||
if (numberOfBytes == 0)
|
||||
return true;
|
||||
|
||||
FileOutputStream out (*this, 8192);
|
||||
|
|
@ -682,11 +684,9 @@ bool File::appendData (const void* const dataToAppend,
|
|||
}
|
||||
|
||||
bool File::replaceWithData (const void* const dataToWrite,
|
||||
const int numberOfBytes) const
|
||||
const size_t numberOfBytes) const
|
||||
{
|
||||
jassert (numberOfBytes >= 0); // a negative number of bytes??
|
||||
|
||||
if (numberOfBytes <= 0)
|
||||
if (numberOfBytes == 0)
|
||||
return deleteFile();
|
||||
|
||||
TemporaryFile tempFile (*this, TemporaryFile::useHiddenFile);
|
||||
|
|
|
|||
|
|
@ -623,7 +623,7 @@ public:
|
|||
@returns false if it can't write to the file for some reason
|
||||
*/
|
||||
bool appendData (const void* dataToAppend,
|
||||
int numberOfBytes) const;
|
||||
size_t numberOfBytes) const;
|
||||
|
||||
/** Replaces this file's contents with a given block of data.
|
||||
|
||||
|
|
@ -640,7 +640,7 @@ public:
|
|||
@see appendText
|
||||
*/
|
||||
bool replaceWithData (const void* dataToWrite,
|
||||
int numberOfBytes) const;
|
||||
size_t numberOfBytes) const;
|
||||
|
||||
/** Appends a string to the end of the file.
|
||||
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ bool FileOutputStream::flushBuffer()
|
|||
|
||||
if (bytesInBuffer > 0)
|
||||
{
|
||||
ok = (writeInternal (buffer, bytesInBuffer) == bytesInBuffer);
|
||||
ok = (writeInternal (buffer, bytesInBuffer) == (ssize_t) bytesInBuffer);
|
||||
bytesInBuffer = 0;
|
||||
}
|
||||
|
||||
|
|
@ -80,13 +80,13 @@ void FileOutputStream::flush()
|
|||
flushInternal();
|
||||
}
|
||||
|
||||
bool FileOutputStream::write (const void* const src, const int numBytes)
|
||||
bool FileOutputStream::write (const void* const src, const size_t numBytes)
|
||||
{
|
||||
jassert (src != nullptr && numBytes >= 0);
|
||||
jassert (src != nullptr && ((ssize_t) numBytes) >= 0);
|
||||
|
||||
if (bytesInBuffer + numBytes < bufferSize)
|
||||
{
|
||||
memcpy (buffer + bytesInBuffer, src, (size_t) numBytes);
|
||||
memcpy (buffer + bytesInBuffer, src, numBytes);
|
||||
bytesInBuffer += numBytes;
|
||||
currentPosition += numBytes;
|
||||
}
|
||||
|
|
@ -97,32 +97,32 @@ bool FileOutputStream::write (const void* const src, const int numBytes)
|
|||
|
||||
if (numBytes < bufferSize)
|
||||
{
|
||||
memcpy (buffer + bytesInBuffer, src, (size_t) numBytes);
|
||||
memcpy (buffer + bytesInBuffer, src, numBytes);
|
||||
bytesInBuffer += numBytes;
|
||||
currentPosition += numBytes;
|
||||
}
|
||||
else
|
||||
{
|
||||
const int bytesWritten = writeInternal (src, numBytes);
|
||||
const ssize_t bytesWritten = writeInternal (src, numBytes);
|
||||
|
||||
if (bytesWritten < 0)
|
||||
return false;
|
||||
|
||||
currentPosition += bytesWritten;
|
||||
return bytesWritten == numBytes;
|
||||
return bytesWritten == (ssize_t) numBytes;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void FileOutputStream::writeRepeatedByte (uint8 byte, int numBytes)
|
||||
void FileOutputStream::writeRepeatedByte (uint8 byte, size_t numBytes)
|
||||
{
|
||||
jassert (numBytes >= 0);
|
||||
jassert (((ssize_t) numBytes) >= 0);
|
||||
|
||||
if (bytesInBuffer + numBytes < bufferSize)
|
||||
{
|
||||
memset (buffer + bytesInBuffer, byte, (size_t) numBytes);
|
||||
memset (buffer + bytesInBuffer, byte, numBytes);
|
||||
bytesInBuffer += numBytes;
|
||||
currentPosition += numBytes;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -90,8 +90,8 @@ public:
|
|||
void flush();
|
||||
int64 getPosition();
|
||||
bool setPosition (int64 pos);
|
||||
bool write (const void* data, int numBytes);
|
||||
void writeRepeatedByte (uint8 byte, int numTimesToRepeat);
|
||||
bool write (const void* data, size_t numBytes);
|
||||
void writeRepeatedByte (uint8 byte, size_t numTimesToRepeat);
|
||||
|
||||
|
||||
private:
|
||||
|
|
@ -100,15 +100,15 @@ private:
|
|||
void* fileHandle;
|
||||
Result status;
|
||||
int64 currentPosition;
|
||||
int bufferSize, bytesInBuffer;
|
||||
size_t bufferSize, bytesInBuffer;
|
||||
HeapBlock <char> buffer;
|
||||
|
||||
void openHandle();
|
||||
void closeHandle();
|
||||
void flushInternal();
|
||||
bool flushBuffer();
|
||||
int64 setPositionInternal (int64 newPosition);
|
||||
int writeInternal (const void* data, int numBytes);
|
||||
int64 setPositionInternal (int64);
|
||||
ssize_t writeInternal (const void*, size_t);
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (FileOutputStream)
|
||||
};
|
||||
|
|
|
|||
|
|
@ -400,7 +400,7 @@ private:
|
|||
|
||||
static void writeSpaces (OutputStream& out, int numSpaces)
|
||||
{
|
||||
out.writeRepeatedByte (' ', numSpaces);
|
||||
out.writeRepeatedByte (' ', (size_t) numSpaces);
|
||||
}
|
||||
|
||||
static void writeArray (OutputStream& out, const Array<var>& array,
|
||||
|
|
|
|||
|
|
@ -494,19 +494,19 @@ void FileOutputStream::closeHandle()
|
|||
}
|
||||
}
|
||||
|
||||
int FileOutputStream::writeInternal (const void* const data, const int numBytes)
|
||||
ssize_t FileOutputStream::writeInternal (const void* const data, const size_t numBytes)
|
||||
{
|
||||
ssize_t result = 0;
|
||||
|
||||
if (fileHandle != 0)
|
||||
{
|
||||
result = ::write (getFD (fileHandle), data, (size_t) numBytes);
|
||||
result = ::write (getFD (fileHandle), data, numBytes);
|
||||
|
||||
if (result == -1)
|
||||
status = getResultForErrno();
|
||||
}
|
||||
|
||||
return (int) result;
|
||||
return result;
|
||||
}
|
||||
|
||||
void FileOutputStream::flushInternal()
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ namespace WindowsFileHelpers
|
|||
const size_t numBytes = CharPointer_UTF16::getBytesRequiredFor (path.getCharPointer()) + 4;
|
||||
HeapBlock<WCHAR> pathCopy;
|
||||
pathCopy.calloc (numBytes, 1);
|
||||
path.copyToUTF16 (pathCopy, (int) numBytes);
|
||||
path.copyToUTF16 (pathCopy, numBytes);
|
||||
|
||||
if (PathStripToRoot (pathCopy))
|
||||
path = static_cast <const WCHAR*> (pathCopy);
|
||||
|
|
@ -184,7 +184,7 @@ bool File::moveToTrash() const
|
|||
const size_t numBytes = CharPointer_UTF16::getBytesRequiredFor (fullPath.getCharPointer()) + 8;
|
||||
HeapBlock<WCHAR> doubleNullTermPath;
|
||||
doubleNullTermPath.calloc (numBytes, 1);
|
||||
fullPath.copyToUTF16 (doubleNullTermPath, (int) numBytes);
|
||||
fullPath.copyToUTF16 (doubleNullTermPath, numBytes);
|
||||
|
||||
SHFILEOPSTRUCT fos = { 0 };
|
||||
fos.wFunc = FO_DELETE;
|
||||
|
|
@ -278,7 +278,7 @@ void FileOutputStream::closeHandle()
|
|||
CloseHandle ((HANDLE) fileHandle);
|
||||
}
|
||||
|
||||
int FileOutputStream::writeInternal (const void* buffer, int numBytes)
|
||||
ssize_t FileOutputStream::writeInternal (const void* buffer, size_t numBytes)
|
||||
{
|
||||
if (fileHandle != nullptr)
|
||||
{
|
||||
|
|
@ -286,7 +286,7 @@ int FileOutputStream::writeInternal (const void* buffer, int numBytes)
|
|||
if (! WriteFile ((HANDLE) fileHandle, buffer, (DWORD) numBytes, &actualNum, 0))
|
||||
status = WindowsFileHelpers::getResultForLastError();
|
||||
|
||||
return (int) actualNum;
|
||||
return (ssize_t) actualNum;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -415,7 +415,7 @@ String URL::removeEscapeChars (const String& s)
|
|||
|
||||
// We need to operate on the string as raw UTF8 chars, and then recombine them into unicode
|
||||
// after all the replacements have been made, so that multi-byte chars are handled.
|
||||
Array<char> utf8 (result.toUTF8().getAddress(), result.getNumBytesAsUTF8());
|
||||
Array<char> utf8 (result.toUTF8().getAddress(), (int) result.getNumBytesAsUTF8());
|
||||
|
||||
for (int i = 0; i < utf8.size(); ++i)
|
||||
{
|
||||
|
|
@ -440,7 +440,7 @@ String URL::addEscapeChars (const String& s, const bool isParameter)
|
|||
const CharPointer_UTF8 legalChars (isParameter ? "_-.*!'()"
|
||||
: ",$_-.*!'()");
|
||||
|
||||
Array<char> utf8 (s.toUTF8().getAddress(), s.getNumBytesAsUTF8());
|
||||
Array<char> utf8 (s.toUTF8().getAddress(), (int) s.getNumBytesAsUTF8());
|
||||
|
||||
for (int i = 0; i < utf8.size(); ++i)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -68,37 +68,37 @@ void MemoryOutputStream::reset() noexcept
|
|||
size = 0;
|
||||
}
|
||||
|
||||
void MemoryOutputStream::prepareToWrite (int numBytes)
|
||||
void MemoryOutputStream::prepareToWrite (size_t numBytes)
|
||||
{
|
||||
jassert (numBytes >= 0);
|
||||
size_t storageNeeded = position + (size_t) numBytes;
|
||||
size_t storageNeeded = position + numBytes;
|
||||
|
||||
if (storageNeeded >= data.getSize())
|
||||
data.ensureSize ((storageNeeded + jmin (storageNeeded / 2, (size_t) (1024 * 1024)) + 32) & ~31u);
|
||||
}
|
||||
|
||||
bool MemoryOutputStream::write (const void* const buffer, int howMany)
|
||||
bool MemoryOutputStream::write (const void* const buffer, size_t howMany)
|
||||
{
|
||||
jassert (buffer != nullptr && howMany >= 0);
|
||||
jassert (buffer != nullptr && ((ssize_t) howMany) >= 0);
|
||||
|
||||
if (howMany > 0)
|
||||
{
|
||||
prepareToWrite (howMany);
|
||||
memcpy (static_cast<char*> (data.getData()) + position, buffer, (size_t) howMany);
|
||||
position += (size_t) howMany;
|
||||
memcpy (static_cast<char*> (data.getData()) + position, buffer, howMany);
|
||||
position += howMany;
|
||||
size = jmax (size, position);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void MemoryOutputStream::writeRepeatedByte (uint8 byte, int howMany)
|
||||
void MemoryOutputStream::writeRepeatedByte (uint8 byte, size_t howMany)
|
||||
{
|
||||
if (howMany > 0)
|
||||
{
|
||||
prepareToWrite (howMany);
|
||||
memset (static_cast<char*> (data.getData()) + position, byte, (size_t) howMany);
|
||||
position += (size_t) howMany;
|
||||
memset (static_cast<char*> (data.getData()) + position, byte, howMany);
|
||||
position += howMany;
|
||||
size = jmax (size, position);
|
||||
}
|
||||
}
|
||||
|
|
@ -160,7 +160,8 @@ String MemoryOutputStream::toString() const
|
|||
|
||||
OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const MemoryOutputStream& streamToRead)
|
||||
{
|
||||
const int dataSize = (int) streamToRead.getDataSize();
|
||||
const size_t dataSize = streamToRead.getDataSize();
|
||||
|
||||
if (dataSize > 0)
|
||||
stream.write (streamToRead.getData(), dataSize);
|
||||
|
||||
|
|
|
|||
|
|
@ -107,11 +107,11 @@ public:
|
|||
*/
|
||||
void flush();
|
||||
|
||||
bool write (const void* buffer, int howMany);
|
||||
bool write (const void* buffer, size_t howMany);
|
||||
int64 getPosition() { return position; }
|
||||
bool setPosition (int64 newPosition);
|
||||
int writeFromInputStream (InputStream& source, int64 maxNumBytesToWrite);
|
||||
void writeRepeatedByte (uint8 byte, int numTimesToRepeat);
|
||||
void writeRepeatedByte (uint8 byte, size_t numTimesToRepeat);
|
||||
|
||||
private:
|
||||
//==============================================================================
|
||||
|
|
@ -120,7 +120,7 @@ private:
|
|||
size_t position, size;
|
||||
|
||||
void trimExternalBlockSize();
|
||||
void prepareToWrite (int numBytes);
|
||||
void prepareToWrite (size_t);
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MemoryOutputStream)
|
||||
};
|
||||
|
|
|
|||
|
|
@ -74,9 +74,9 @@ void OutputStream::writeByte (char byte)
|
|||
write (&byte, 1);
|
||||
}
|
||||
|
||||
void OutputStream::writeRepeatedByte (uint8 byte, int numTimesToRepeat)
|
||||
void OutputStream::writeRepeatedByte (uint8 byte, size_t numTimesToRepeat)
|
||||
{
|
||||
while (--numTimesToRepeat >= 0)
|
||||
for (size_t i = 0; i < numTimesToRepeat; ++i)
|
||||
writeByte ((char) byte);
|
||||
}
|
||||
|
||||
|
|
@ -170,8 +170,8 @@ void OutputStream::writeString (const String& text)
|
|||
{
|
||||
// (This avoids using toUTF8() to prevent the memory bloat that it would leave behind
|
||||
// if lots of large, persistent strings were to be written to streams).
|
||||
const int numBytes = text.getNumBytesAsUTF8() + 1;
|
||||
HeapBlock<char> temp ((size_t) numBytes);
|
||||
const size_t numBytes = text.getNumBytesAsUTF8() + 1;
|
||||
HeapBlock<char> temp (numBytes);
|
||||
text.copyToUTF8 (temp, numBytes);
|
||||
write (temp, numBytes);
|
||||
}
|
||||
|
|
@ -288,14 +288,14 @@ JUCE_API OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const cha
|
|||
|
||||
JUCE_API OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const char* const text)
|
||||
{
|
||||
stream.write (text, (int) strlen (text));
|
||||
stream.write (text, strlen (text));
|
||||
return stream;
|
||||
}
|
||||
|
||||
JUCE_API OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const MemoryBlock& data)
|
||||
{
|
||||
if (data.getSize() > 0)
|
||||
stream.write (data.getData(), (int) data.getSize());
|
||||
stream.write (data.getData(), data.getSize());
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,11 +84,11 @@ public:
|
|||
types of data which use this to do the work.
|
||||
|
||||
@param dataToWrite the target buffer to receive the data. This must not be null.
|
||||
@param numberOfBytes the number of bytes to write. This must not be negative.
|
||||
@param numberOfBytes the number of bytes to write.
|
||||
@returns false if the write operation fails for some reason
|
||||
*/
|
||||
virtual bool write (const void* dataToWrite,
|
||||
int numberOfBytes) = 0;
|
||||
size_t numberOfBytes) = 0;
|
||||
|
||||
//==============================================================================
|
||||
/** Writes a single byte to the stream.
|
||||
|
|
@ -160,7 +160,7 @@ public:
|
|||
virtual void writeDoubleBigEndian (double value);
|
||||
|
||||
/** Writes a byte to the output stream a given number of times. */
|
||||
virtual void writeRepeatedByte (uint8 byte, int numTimesToRepeat);
|
||||
virtual void writeRepeatedByte (uint8 byte, size_t numTimesToRepeat);
|
||||
|
||||
/** Writes a condensed binary encoding of a 32-bit integer.
|
||||
|
||||
|
|
|
|||
|
|
@ -223,7 +223,7 @@ public:
|
|||
to the destination buffer before stopping.
|
||||
*/
|
||||
template <typename CharPointer>
|
||||
int writeWithDestByteLimit (const CharPointer& src, const int maxDestBytes) noexcept
|
||||
size_t writeWithDestByteLimit (const CharPointer& src, const size_t maxDestBytes) noexcept
|
||||
{
|
||||
return CharacterFunctions::copyWithDestByteLimit (*this, src, maxDestBytes);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -303,7 +303,7 @@ public:
|
|||
to the destination buffer before stopping.
|
||||
*/
|
||||
template <typename CharPointer>
|
||||
int writeWithDestByteLimit (const CharPointer& src, const int maxDestBytes) noexcept
|
||||
size_t writeWithDestByteLimit (const CharPointer& src, const size_t maxDestBytes) noexcept
|
||||
{
|
||||
return CharacterFunctions::copyWithDestByteLimit (*this, src, maxDestBytes);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -233,7 +233,7 @@ public:
|
|||
to the destination buffer before stopping.
|
||||
*/
|
||||
template <typename CharPointer>
|
||||
int writeWithDestByteLimit (const CharPointer& src, const int maxDestBytes) noexcept
|
||||
size_t writeWithDestByteLimit (const CharPointer& src, const size_t maxDestBytes) noexcept
|
||||
{
|
||||
return CharacterFunctions::copyWithDestByteLimit (*this, src, maxDestBytes);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -385,7 +385,7 @@ public:
|
|||
to the destination buffer before stopping.
|
||||
*/
|
||||
template <typename CharPointer>
|
||||
int writeWithDestByteLimit (const CharPointer& src, const int maxDestBytes) noexcept
|
||||
size_t writeWithDestByteLimit (const CharPointer& src, const size_t maxDestBytes) noexcept
|
||||
{
|
||||
return CharacterFunctions::copyWithDestByteLimit (*this, src, maxDestBytes);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -324,15 +324,16 @@ public:
|
|||
/** Copies characters from one string to another, up to a null terminator
|
||||
or a given byte size limit. */
|
||||
template <typename DestCharPointerType, typename SrcCharPointerType>
|
||||
static int copyWithDestByteLimit (DestCharPointerType& dest, SrcCharPointerType src, int maxBytes) noexcept
|
||||
static size_t copyWithDestByteLimit (DestCharPointerType& dest, SrcCharPointerType src, size_t maxBytesToWrite) noexcept
|
||||
{
|
||||
typename DestCharPointerType::CharType const* const startAddress = dest.getAddress();
|
||||
ssize_t maxBytes = (ssize_t) maxBytesToWrite;
|
||||
maxBytes -= sizeof (typename DestCharPointerType::CharType); // (allow for a terminating null)
|
||||
|
||||
for (;;)
|
||||
{
|
||||
const juce_wchar c = src.getAndAdvance();
|
||||
const int bytesNeeded = (int) DestCharPointerType::getBytesRequiredFor (c);
|
||||
const size_t bytesNeeded = DestCharPointerType::getBytesRequiredFor (c);
|
||||
|
||||
maxBytes -= bytesNeeded;
|
||||
if (c == 0 || maxBytes < 0)
|
||||
|
|
@ -343,7 +344,8 @@ public:
|
|||
|
||||
dest.writeNull();
|
||||
|
||||
return (int) ((size_t) getAddressDifference (dest.getAddress(), startAddress) + sizeof (typename DestCharPointerType::CharType));
|
||||
return (size_t) getAddressDifference (dest.getAddress(), startAddress)
|
||||
+ sizeof (typename DestCharPointerType::CharType);
|
||||
}
|
||||
|
||||
/** Copies characters from one string to another, up to a null terminator
|
||||
|
|
|
|||
|
|
@ -731,7 +731,7 @@ JUCE_API String& JUCE_CALLTYPE operator<< (String& s1, const double number)
|
|||
|
||||
JUCE_API OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const String& text)
|
||||
{
|
||||
const int numBytes = text.getNumBytesAsUTF8();
|
||||
const size_t numBytes = text.getNumBytesAsUTF8();
|
||||
|
||||
#if (JUCE_STRING_UTF_TYPE == 8)
|
||||
stream.write (text.getCharPointer().getAddress(), numBytes);
|
||||
|
|
@ -2020,36 +2020,36 @@ const wchar_t* String::toWideCharPointer() const
|
|||
template <class CharPointerType_Src, class CharPointerType_Dest>
|
||||
struct StringCopier
|
||||
{
|
||||
static int copyToBuffer (const CharPointerType_Src& source, typename CharPointerType_Dest::CharType* const buffer, const int maxBufferSizeBytes)
|
||||
static size_t copyToBuffer (const CharPointerType_Src& source, typename CharPointerType_Dest::CharType* const buffer, const size_t maxBufferSizeBytes)
|
||||
{
|
||||
jassert (maxBufferSizeBytes >= 0); // keep this value positive, or no characters will be copied!
|
||||
jassert (((ssize_t) maxBufferSizeBytes) >= 0); // keep this value positive!
|
||||
|
||||
if (buffer == nullptr)
|
||||
return (int) (CharPointerType_Dest::getBytesRequiredFor (source) + sizeof (typename CharPointerType_Dest::CharType));
|
||||
return CharPointerType_Dest::getBytesRequiredFor (source) + sizeof (typename CharPointerType_Dest::CharType);
|
||||
|
||||
return CharPointerType_Dest (buffer).writeWithDestByteLimit (source, maxBufferSizeBytes);
|
||||
}
|
||||
};
|
||||
|
||||
int String::copyToUTF8 (CharPointer_UTF8::CharType* const buffer, const int maxBufferSizeBytes) const noexcept
|
||||
size_t String::copyToUTF8 (CharPointer_UTF8::CharType* const buffer, size_t maxBufferSizeBytes) const noexcept
|
||||
{
|
||||
return StringCopier <CharPointerType, CharPointer_UTF8>::copyToBuffer (text, buffer, maxBufferSizeBytes);
|
||||
}
|
||||
|
||||
int String::copyToUTF16 (CharPointer_UTF16::CharType* const buffer, int maxBufferSizeBytes) const noexcept
|
||||
size_t String::copyToUTF16 (CharPointer_UTF16::CharType* const buffer, size_t maxBufferSizeBytes) const noexcept
|
||||
{
|
||||
return StringCopier <CharPointerType, CharPointer_UTF16>::copyToBuffer (text, buffer, maxBufferSizeBytes);
|
||||
}
|
||||
|
||||
int String::copyToUTF32 (CharPointer_UTF32::CharType* const buffer, int maxBufferSizeBytes) const noexcept
|
||||
size_t String::copyToUTF32 (CharPointer_UTF32::CharType* const buffer, size_t maxBufferSizeBytes) const noexcept
|
||||
{
|
||||
return StringCopier <CharPointerType, CharPointer_UTF32>::copyToBuffer (text, buffer, maxBufferSizeBytes);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
int String::getNumBytesAsUTF8() const noexcept
|
||||
size_t String::getNumBytesAsUTF8() const noexcept
|
||||
{
|
||||
return (int) CharPointer_UTF8::getBytesRequiredFor (text);
|
||||
return CharPointer_UTF8::getBytesRequiredFor (text);
|
||||
}
|
||||
|
||||
String String::fromUTF8 (const char* const buffer, int bufferSizeBytes)
|
||||
|
|
|
|||
|
|
@ -1096,7 +1096,7 @@ public:
|
|||
The number returned does NOT include the trailing zero.
|
||||
@see toUTF8, copyToUTF8
|
||||
*/
|
||||
int getNumBytesAsUTF8() const noexcept;
|
||||
size_t getNumBytesAsUTF8() const noexcept;
|
||||
|
||||
//==============================================================================
|
||||
/** Copies the string to a buffer as UTF-8 characters.
|
||||
|
|
@ -1114,7 +1114,7 @@ public:
|
|||
end, and will return the number of bytes that were actually used.
|
||||
@see CharPointer_UTF8::writeWithDestByteLimit
|
||||
*/
|
||||
int copyToUTF8 (CharPointer_UTF8::CharType* destBuffer, int maxBufferSizeBytes) const noexcept;
|
||||
size_t copyToUTF8 (CharPointer_UTF8::CharType* destBuffer, size_t maxBufferSizeBytes) const noexcept;
|
||||
|
||||
/** Copies the string to a buffer as UTF-16 characters.
|
||||
|
||||
|
|
@ -1131,7 +1131,7 @@ public:
|
|||
end, and will return the number of bytes that were actually used.
|
||||
@see CharPointer_UTF16::writeWithDestByteLimit
|
||||
*/
|
||||
int copyToUTF16 (CharPointer_UTF16::CharType* destBuffer, int maxBufferSizeBytes) const noexcept;
|
||||
size_t copyToUTF16 (CharPointer_UTF16::CharType* destBuffer, size_t maxBufferSizeBytes) const noexcept;
|
||||
|
||||
/** Copies the string to a buffer as UTF-32 characters.
|
||||
|
||||
|
|
@ -1148,7 +1148,7 @@ public:
|
|||
end, and will return the number of bytes that were actually used.
|
||||
@see CharPointer_UTF32::writeWithDestByteLimit
|
||||
*/
|
||||
int copyToUTF32 (CharPointer_UTF32::CharType* destBuffer, int maxBufferSizeBytes) const noexcept;
|
||||
size_t copyToUTF32 (CharPointer_UTF32::CharType* destBuffer, size_t maxBufferSizeBytes) const noexcept;
|
||||
|
||||
//==============================================================================
|
||||
/** Increases the string's internally allocated storage.
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ String ChildProcess::readAllProcessOutput()
|
|||
if (num <= 0)
|
||||
break;
|
||||
|
||||
result.write (buffer, num);
|
||||
result.write (buffer, (size_t) num);
|
||||
}
|
||||
|
||||
return result.toString();
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ public:
|
|||
zlibNamespace::deflateEnd (&stream);
|
||||
}
|
||||
|
||||
bool write (const uint8* data, unsigned int dataSize, OutputStream& out)
|
||||
bool write (const uint8* data, size_t dataSize, OutputStream& out)
|
||||
{
|
||||
// When you call flush() on a gzip stream, the stream is closed, and you can
|
||||
// no longer continue to write data to it!
|
||||
|
|
@ -62,7 +62,7 @@ public:
|
|||
void finish (OutputStream& out)
|
||||
{
|
||||
const uint8* data = nullptr;
|
||||
unsigned int dataSize = 0;
|
||||
size_t dataSize = 0;
|
||||
|
||||
while (! finished)
|
||||
doNextBlock (data, dataSize, out, Z_FINISH);
|
||||
|
|
@ -76,9 +76,10 @@ private:
|
|||
bool isFirstDeflate, streamIsValid, finished;
|
||||
zlibNamespace::Bytef buffer[32768];
|
||||
|
||||
bool doNextBlock (const uint8*& data, unsigned int& dataSize, OutputStream& out, const int flushMode)
|
||||
bool doNextBlock (const uint8*& data, size_t& dataSize, OutputStream& out, const int flushMode)
|
||||
{
|
||||
using namespace zlibNamespace;
|
||||
|
||||
if (streamIsValid)
|
||||
{
|
||||
stream.next_in = const_cast <uint8*> (data);
|
||||
|
|
@ -99,8 +100,8 @@ private:
|
|||
{
|
||||
data += dataSize - stream.avail_in;
|
||||
dataSize = stream.avail_in;
|
||||
const int bytesDone = ((int) sizeof (buffer)) - (int) stream.avail_out;
|
||||
return bytesDone <= 0 || out.write (buffer, bytesDone);
|
||||
const ssize_t bytesDone = sizeof (buffer) - (ssize_t) stream.avail_out;
|
||||
return bytesDone <= 0 || out.write (buffer, (size_t) bytesDone);
|
||||
}
|
||||
|
||||
default:
|
||||
|
|
@ -136,12 +137,11 @@ void GZIPCompressorOutputStream::flush()
|
|||
destStream->flush();
|
||||
}
|
||||
|
||||
bool GZIPCompressorOutputStream::write (const void* destBuffer, int howMany)
|
||||
bool GZIPCompressorOutputStream::write (const void* destBuffer, size_t howMany)
|
||||
{
|
||||
jassert (destBuffer != nullptr && howMany >= 0);
|
||||
|
||||
return helper->write (static_cast <const uint8*> (destBuffer),
|
||||
(unsigned int) howMany, *destStream);
|
||||
return helper->write (static_cast <const uint8*> (destBuffer), howMany, *destStream);
|
||||
}
|
||||
|
||||
int64 GZIPCompressorOutputStream::getPosition()
|
||||
|
|
@ -182,8 +182,8 @@ public:
|
|||
for (int k = (int) data.getSize(); --k >= 0;)
|
||||
data[k] = (char) rng.nextInt (255);
|
||||
|
||||
original.write (data.getData(), (int) data.getSize());
|
||||
zipper .write (data.getData(), (int) data.getSize());
|
||||
original << data;
|
||||
zipper << data;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ public:
|
|||
|
||||
int64 getPosition();
|
||||
bool setPosition (int64 newPosition);
|
||||
bool write (const void* destBuffer, int howMany);
|
||||
bool write (const void* destBuffer, size_t howMany);
|
||||
|
||||
/** These are preset values that can be used for the constructor's windowBits paramter.
|
||||
For more info about this, see the zlib documentation for its windowBits parameter.
|
||||
|
|
|
|||
|
|
@ -520,7 +520,7 @@ private:
|
|||
return false;
|
||||
|
||||
checksum = juce_crc32 (checksum, buffer, (unsigned int) bytesRead);
|
||||
target.write (buffer, bytesRead);
|
||||
target.write (buffer, (size_t) bytesRead);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ namespace JPEGHelpers
|
|||
JuceJpegDest* const dest = static_cast <JuceJpegDest*> (cinfo->dest);
|
||||
|
||||
const size_t numToWrite = jpegBufferSize - dest->free_in_buffer;
|
||||
dest->output->write (dest->buffer, (int) numToWrite);
|
||||
dest->output->write (dest->buffer, numToWrite);
|
||||
}
|
||||
|
||||
static boolean jpegWriteFlush (j_compress_ptr cinfo)
|
||||
|
|
@ -204,7 +204,7 @@ namespace JPEGHelpers
|
|||
dest->next_output_byte = reinterpret_cast <JOCTET*> (dest->buffer);
|
||||
dest->free_in_buffer = jpegBufferSize;
|
||||
|
||||
return (boolean) dest->output->write (dest->buffer, numToWrite);
|
||||
return (boolean) dest->output->write (dest->buffer, (size_t) numToWrite);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ namespace PNGHelpers
|
|||
|
||||
static void JUCE_CDECL writeDataCallback (png_structp png, png_bytep data, png_size_t length)
|
||||
{
|
||||
static_cast<OutputStream*> (png_get_io_ptr (png))->write (data, (int) length);
|
||||
static_cast<OutputStream*> (png_get_io_ptr (png))->write (data, length);
|
||||
}
|
||||
|
||||
#if ! JUCE_USING_COREIMAGE_LOADER
|
||||
|
|
|
|||
|
|
@ -135,7 +135,8 @@ namespace ClipboardHelpers
|
|||
reply.time = evt.time;
|
||||
|
||||
HeapBlock <char> data;
|
||||
int propertyFormat = 0, numDataItems = 0;
|
||||
int propertyFormat = 0;
|
||||
size_t numDataItems = 0;
|
||||
|
||||
if (evt.selection == XA_PRIMARY || evt.selection == ClipboardHelpers::atom_CLIPBOARD)
|
||||
{
|
||||
|
|
@ -167,7 +168,7 @@ namespace ClipboardHelpers
|
|||
|
||||
if (data != nullptr)
|
||||
{
|
||||
const int maxReasonableSelectionSize = 1000000;
|
||||
const size_t maxReasonableSelectionSize = 1000000;
|
||||
|
||||
// for very big chunks of data, we should use the "INCR" protocol , which is a pain in the *ss
|
||||
if (evt.property != None && numDataItems < maxReasonableSelectionSize)
|
||||
|
|
|
|||
|
|
@ -236,7 +236,7 @@ namespace DragAndDropHelpers
|
|||
|
||||
for (int i = 0; i < fileNames.size(); ++i)
|
||||
{
|
||||
const int bytesWritten = fileNames[i].copyToUTF16 (fname, 2048);
|
||||
const size_t bytesWritten = fileNames[i].copyToUTF16 (fname, 2048);
|
||||
fname = reinterpret_cast<WCHAR*> (addBytesToPointer (fname, bytesWritten));
|
||||
}
|
||||
|
||||
|
|
@ -285,7 +285,7 @@ bool DragAndDropContainer::performExternalDragDropOfText (const String& text)
|
|||
medium.hGlobal = GlobalAlloc (GMEM_MOVEABLE | GMEM_ZEROINIT, numBytes + 2);
|
||||
WCHAR* const data = static_cast <WCHAR*> (GlobalLock (medium.hGlobal));
|
||||
|
||||
text.copyToUTF16 (data, (int) numBytes);
|
||||
text.copyToUTF16 (data, numBytes);
|
||||
format.cfFormat = CF_UNICODETEXT;
|
||||
|
||||
GlobalUnlock (medium.hGlobal);
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ void FileChooser::showPlatformDialog (Array<File>& results, const String& title_
|
|||
|
||||
const String title (title_);
|
||||
HeapBlock<WCHAR> files;
|
||||
const int charsAvailableForResult = 32768;
|
||||
const size_t charsAvailableForResult = 32768;
|
||||
files.calloc (charsAvailableForResult + 1);
|
||||
int filenameOffset = 0;
|
||||
|
||||
|
|
@ -215,12 +215,12 @@ void FileChooser::showPlatformDialog (Array<File>& results, const String& title_
|
|||
info.customComponent->enterModalState();
|
||||
}
|
||||
|
||||
const int filterSpaceNumChars = 2048;
|
||||
const size_t filterSpaceNumChars = 2048;
|
||||
HeapBlock<WCHAR> filters;
|
||||
filters.calloc (filterSpaceNumChars);
|
||||
const int bytesWritten = filter.copyToUTF16 (filters.getData(), filterSpaceNumChars * sizeof (WCHAR));
|
||||
const size_t bytesWritten = filter.copyToUTF16 (filters.getData(), filterSpaceNumChars * sizeof (WCHAR));
|
||||
filter.copyToUTF16 (filters + (bytesWritten / sizeof (WCHAR)),
|
||||
(int) ((filterSpaceNumChars - 1) * sizeof (WCHAR) - bytesWritten));
|
||||
((filterSpaceNumChars - 1) * sizeof (WCHAR) - bytesWritten));
|
||||
|
||||
OPENFILENAMEW of = { 0 };
|
||||
String localPath (info.initialPath);
|
||||
|
|
@ -234,7 +234,7 @@ void FileChooser::showPlatformDialog (Array<File>& results, const String& title_
|
|||
of.lpstrFilter = filters.getData();
|
||||
of.nFilterIndex = 1;
|
||||
of.lpstrFile = files;
|
||||
of.nMaxFile = charsAvailableForResult;
|
||||
of.nMaxFile = (DWORD) charsAvailableForResult;
|
||||
of.lpstrInitialDir = localPath.toWideCharPointer();
|
||||
of.lpstrTitle = title.toWideCharPointer();
|
||||
of.Flags = flags;
|
||||
|
|
|
|||
|
|
@ -3025,7 +3025,7 @@ void SystemClipboard::copyTextToClipboard (const String& text)
|
|||
{
|
||||
if (WCHAR* const data = static_cast <WCHAR*> (GlobalLock (bufH)))
|
||||
{
|
||||
text.copyToUTF16 (data, (int) bytesNeeded);
|
||||
text.copyToUTF16 (data, bytesNeeded);
|
||||
GlobalUnlock (bufH);
|
||||
|
||||
SetClipboardData (CF_UNICODETEXT, bufH);
|
||||
|
|
|
|||
|
|
@ -611,7 +611,7 @@ bool CodeDocument::writeToStream (OutputStream& stream)
|
|||
String temp (lines.getUnchecked(i)->line); // use a copy to avoid bloating the memory footprint of the stored string.
|
||||
const char* utf8 = temp.toUTF8();
|
||||
|
||||
if (! stream.write (utf8, (int) strlen (utf8)))
|
||||
if (! stream.write (utf8, strlen (utf8)))
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue