1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-02-06 04:00:08 +00:00

New class HeapBlock, which provides a safe and object-oriented way to allocate heap space. I've used HeapBlocks to replace almost all uses of malloc/free throughout the codebase.

This commit is contained in:
Julian Storer 2010-01-02 14:55:44 +00:00
parent 8c988319ec
commit 4ed1d791e5
86 changed files with 22712 additions and 22630 deletions

View file

@ -47,15 +47,13 @@ BufferedInputStream::BufferedInputStream (InputStream* const source_,
bufferSize = jmin (jmax (32, sourceSize), bufferSize);
bufferStart = position;
buffer = (char*) juce_malloc (bufferSize);
buffer.malloc (bufferSize);
}
BufferedInputStream::~BufferedInputStream() throw()
{
if (deleteSourceWhenDestroyed)
delete source;
juce_free (buffer);
}
//==============================================================================
@ -94,7 +92,7 @@ void BufferedInputStream::ensureBuffered()
&& position >= bufferStart)
{
const int bytesToKeep = (int) (lastReadPos - position);
memmove (buffer, buffer + position - bufferStart, bytesToKeep);
memmove (buffer, buffer + (int) (position - bufferStart), bytesToKeep);
bufferStart = position;
@ -122,7 +120,7 @@ int BufferedInputStream::read (void* destBuffer, int maxBytesToRead)
if (position >= bufferStart
&& position + maxBytesToRead <= lastReadPos)
{
memcpy (destBuffer, buffer + (position - bufferStart), maxBytesToRead);
memcpy (destBuffer, buffer + (int) (position - bufferStart), maxBytesToRead);
position += maxBytesToRead;
return maxBytesToRead;
@ -140,7 +138,7 @@ int BufferedInputStream::read (void* destBuffer, int maxBytesToRead)
if (bytesAvailable > 0)
{
memcpy (destBuffer, buffer + (position - bufferStart), bytesAvailable);
memcpy (destBuffer, buffer + (int) (position - bufferStart), bytesAvailable);
maxBytesToRead -= bytesAvailable;
bytesRead += bytesAvailable;
position += bytesAvailable;
@ -168,7 +166,7 @@ const String BufferedInputStream::readString()
{
const int maxChars = (int) (lastReadPos - position);
const char* const src = buffer + (position - bufferStart);
const char* const src = buffer + (int) (position - bufferStart);
for (int i = 0; i < maxChars; ++i)
{