Browse Source

Minor string clean-ups. Made key-shortcut indicators in popup menus use icons for shift/command/option on the mac.

tags/2021-05-28
Julian Storer 14 years ago
parent
commit
06d436a3ab
34 changed files with 99 additions and 92 deletions
  1. +1
    -2
      extras/audio plugins/wrapper/RTAS/juce_RTAS_WinUtilities.cpp
  2. +3
    -6
      extras/audio plugins/wrapper/VST/juce_VST_Wrapper.cpp
  3. +1
    -2
      src/audio/audio_file_formats/juce_AiffAudioFormat.cpp
  4. +1
    -1
      src/audio/audio_sources/juce_ResamplingAudioSource.cpp
  5. +1
    -1
      src/audio/dsp/juce_AudioSampleBuffer.cpp
  6. +4
    -8
      src/core/juce_Time.cpp
  7. +1
    -3
      src/cryptography/juce_MD5.cpp
  8. +19
    -8
      src/gui/components/keyboard/juce_KeyPress.cpp
  9. +7
    -0
      src/gui/components/keyboard/juce_KeyPress.h
  10. +1
    -1
      src/gui/components/menus/juce_PopupMenu.cpp
  11. +1
    -2
      src/gui/graphics/drawables/juce_SVGParser.cpp
  12. +1
    -1
      src/io/files/juce_File.cpp
  13. +1
    -2
      src/io/files/juce_ZipFile.cpp
  14. +2
    -1
      src/io/streams/juce_MemoryOutputStream.cpp
  15. +1
    -1
      src/maths/juce_BigInteger.cpp
  16. +8
    -0
      src/memory/juce_HeapBlock.h
  17. +8
    -4
      src/memory/juce_ReferenceCountedObject.h
  18. +1
    -1
      src/native/android/juce_android_Files.cpp
  19. +1
    -1
      src/native/android/juce_android_SystemStats.cpp
  20. +2
    -2
      src/native/common/juce_posix_SharedCode.h
  21. +3
    -3
      src/native/linux/juce_linux_Files.cpp
  22. +1
    -1
      src/native/linux/juce_linux_Fonts.cpp
  23. +1
    -1
      src/native/linux/juce_linux_Network.cpp
  24. +1
    -1
      src/native/linux/juce_linux_SystemStats.cpp
  25. +1
    -4
      src/native/linux/juce_linux_Windowing.cpp
  26. +2
    -2
      src/native/mac/juce_mac_AudioCDBurner.mm
  27. +1
    -2
      src/native/mac/juce_mac_CoreAudio.cpp
  28. +3
    -4
      src/native/mac/juce_mac_Files.mm
  29. +1
    -1
      src/native/mac/juce_mac_Strings.mm
  30. +3
    -5
      src/native/windows/juce_win32_ASIO.cpp
  31. +2
    -3
      src/native/windows/juce_win32_AudioCDReader.cpp
  32. +1
    -2
      src/native/windows/juce_win32_OpenGLComponent.cpp
  33. +1
    -2
      src/native/windows/juce_win32_SystemStats.cpp
  34. +13
    -14
      src/text/juce_String.cpp

+ 1
- 2
extras/audio plugins/wrapper/RTAS/juce_RTAS_WinUtilities.cpp View File

@@ -98,8 +98,7 @@ namespace
if (parent == 0) if (parent == 0)
break; break;
TCHAR windowType [32];
zeromem (windowType, sizeof (windowType));
TCHAR windowType [32] = { 0 };
GetClassName (parent, windowType, 31); GetClassName (parent, windowType, 31);
if (String (windowType).equalsIgnoreCase ("MDIClient")) if (String (windowType).equalsIgnoreCase ("MDIClient"))


+ 3
- 6
extras/audio plugins/wrapper/VST/juce_VST_Wrapper.cpp View File

@@ -180,8 +180,7 @@ namespace
if (parent == 0) if (parent == 0)
break; break;
TCHAR windowType [32];
zeromem (windowType, sizeof (windowType));
TCHAR windowType[32] = { 0 };
GetClassName (parent, windowType, 31); GetClassName (parent, windowType, 31);
if (String (windowType).equalsIgnoreCase ("MDIClient")) if (String (windowType).equalsIgnoreCase ("MDIClient"))
@@ -1253,8 +1252,7 @@ public:
if (parent == 0) if (parent == 0)
break; break;
TCHAR windowType [32];
zeromem (windowType, sizeof (windowType));
TCHAR windowType [32] = { 0 };
GetClassName (parent, windowType, 31); GetClassName (parent, windowType, 31);
if (String (windowType).equalsIgnoreCase ("MDIClient")) if (String (windowType).equalsIgnoreCase ("MDIClient"))
@@ -1489,8 +1487,7 @@ private:
const String getHostName() const String getHostName()
{ {
char host[256];
zeromem (host, sizeof (host));
char host[256] = { 0 };
getHostProductString (host); getHostProductString (host);
return host; return host;
} }


+ 1
- 2
src/audio/audio_file_formats/juce_AiffAudioFormat.cpp View File

@@ -308,8 +308,7 @@ private:
output->writeIntBigEndian (lengthInSamples); output->writeIntBigEndian (lengthInSamples);
output->writeShortBigEndian ((short) bitsPerSample); output->writeShortBigEndian ((short) bitsPerSample);
uint8 sampleRateBytes[10];
zeromem (sampleRateBytes, 10);
uint8 sampleRateBytes[10] = { 0 };
if (sampleRate <= 1) if (sampleRate <= 1)
{ {


+ 1
- 1
src/audio/audio_sources/juce_ResamplingAudioSource.cpp View File

@@ -242,7 +242,7 @@ void ResamplingAudioSource::setFilterCoefficients (double c1, double c2, double
void ResamplingAudioSource::resetFilters() void ResamplingAudioSource::resetFilters()
{ {
zeromem (filterStates, sizeof (FilterState) * numChannels);
filterStates.clear (numChannels);
} }
void ResamplingAudioSource::applyFilter (float* samples, int num, FilterState& fs) void ResamplingAudioSource::applyFilter (float* samples, int num, FilterState& fs)


+ 1
- 1
src/audio/dsp/juce_AudioSampleBuffer.cpp View File

@@ -192,7 +192,7 @@ void AudioSampleBuffer::setSize (const int newNumChannels,
if (avoidReallocating && allocatedBytes >= newTotalBytes) if (avoidReallocating && allocatedBytes >= newTotalBytes)
{ {
if (clearExtraSpace) if (clearExtraSpace)
zeromem (allocatedData, newTotalBytes);
allocatedData.clear (newTotalBytes);
} }
else else
{ {


+ 4
- 8
src/core/juce_Time.cpp View File

@@ -448,16 +448,12 @@ const String Time::getTimeZone() const throw()
_tzset(); _tzset();
#ifdef USE_NEW_SECURE_TIME_FNS #ifdef USE_NEW_SECURE_TIME_FNS
for (int i = 0; i < 2; ++i)
{ {
char name [128];
char name[128] = { 0 };
size_t length; size_t length;
for (int i = 0; i < 2; ++i)
{
zeromem (name, sizeof (name));
_get_tzname (&length, name, 127, i);
zone[i] = name;
}
_get_tzname (&length, name, 127, i);
zone[i] = name;
} }
#else #else
const char** const zonePtr = (const char**) _tzname; const char** const zonePtr = (const char**) _tzname;


+ 1
- 3
src/cryptography/juce_MD5.cpp View File

@@ -216,9 +216,7 @@ void MD5::ProcessContext::finish (void* const result)
const int paddingLength = (index < 56) ? (56 - index) const int paddingLength = (index < 56) ? (56 - index)
: (120 - index); : (120 - index);
uint8 paddingBuffer [64];
zeromem (paddingBuffer, paddingLength);
paddingBuffer [0] = 0x80;
uint8 paddingBuffer[64] = { 0x80 }; // first byte is 0x80, remaining bytes are zero.
processBlock (paddingBuffer, paddingLength); processBlock (paddingBuffer, paddingLength);
processBlock (encodedLength, 8); processBlock (encodedLength, 8);


+ 19
- 8
src/gui/components/keyboard/juce_KeyPress.cpp View File

@@ -234,18 +234,18 @@ const String KeyPress::getTextDescription() const
if (mods.isShiftDown()) if (mods.isShiftDown())
desc << "shift + "; desc << "shift + ";
#if JUCE_MAC
// only do this on the mac, because on Windows ctrl and command are the same,
// and this would get confusing
if (mods.isCommandDown())
desc << "command + ";
#if JUCE_MAC
if (mods.isAltDown()) if (mods.isAltDown())
desc << "option + "; desc << "option + ";
#else
// only do this on the mac, because on Windows ctrl and command are the same,
// and this would get confusing
if (mods.isCommandDown())
desc << "command + ";
#else
if (mods.isAltDown()) if (mods.isAltDown())
desc << "alt + "; desc << "alt + ";
#endif
#endif
for (int i = 0; i < numElementsInArray (KeyPressHelpers::translations); ++i) for (int i = 0; i < numElementsInArray (KeyPressHelpers::translations); ++i)
if (keyCode == KeyPressHelpers::translations[i].code) if (keyCode == KeyPressHelpers::translations[i].code)
@@ -278,5 +278,16 @@ const String KeyPress::getTextDescription() const
return desc; return desc;
} }
const String KeyPress::getTextDescriptionWithIcons() const
{
#if JUCE_MAC
return getTextDescription().replace ("shift + ", String::charToString (0x21e7))
.replace ("command + ", String::charToString (0x2318))
.replace ("option + ", String::charToString (0x2325));
#else
return getTextDescription();
#endif
}
END_JUCE_NAMESPACE END_JUCE_NAMESPACE

+ 7
- 0
src/gui/components/keyboard/juce_KeyPress.h View File

@@ -148,6 +148,13 @@ public:
*/ */
const String getTextDescription() const; const String getTextDescription() const;
/** Creates a textual description of the key combination, using unicode icon symbols if possible.
On OSX, this uses the Apple symbols for command, option, shift, etc, instead of the textual
modifier key descriptions that are returned by getTextDescription()
*/
const String getTextDescriptionWithIcons() const;
//============================================================================== //==============================================================================
/** Checks whether the user is currently holding down the keys that make up this /** Checks whether the user is currently holding down the keys that make up this
KeyPress. KeyPress.


+ 1
- 1
src/gui/components/menus/juce_PopupMenu.cpp View File

@@ -76,7 +76,7 @@ public:
for (int i = 0; i < keyPresses.size(); ++i) for (int i = 0; i < keyPresses.size(); ++i)
{ {
const String key (keyPresses.getReference(i).getTextDescription());
const String key (keyPresses.getReference(i).getTextDescriptionWithIcons());
if (shortcutKey.isNotEmpty()) if (shortcutKey.isNotEmpty())
shortcutKey << ", "; shortcutKey << ", ";


+ 1
- 2
src/gui/graphics/drawables/juce_SVGParser.cpp View File

@@ -1083,8 +1083,7 @@ private:
{ {
if (s [index] == '#') if (s [index] == '#')
{ {
uint32 hex [6];
zeromem (hex, sizeof (hex));
uint32 hex[6] = { 0 };
int numChars = 0; int numChars = 0;
for (int i = 6; --i >= 0;) for (int i = 6; --i >= 0;)


+ 1
- 1
src/io/files/juce_File.cpp View File

@@ -369,7 +369,7 @@ bool File::isAChildOf (const File& potentialParent) const
//============================================================================== //==============================================================================
bool File::isAbsolutePath (const String& path) bool File::isAbsolutePath (const String& path)
{ {
return path.startsWithChar ('/') || path.startsWithChar ('\\')
return path.startsWithChar (separator)
#if JUCE_WINDOWS #if JUCE_WINDOWS
|| (path.isNotEmpty() && path[1] == ':'); || (path.isNotEmpty() && path[1] == ':');
#else #else


+ 1
- 2
src/io/files/juce_ZipFile.cpp View File

@@ -343,8 +343,7 @@ int ZipFile::findEndOfZipEntryTable (InputStream& input, int& numEntries)
int64 pos = in.getPosition(); int64 pos = in.getPosition();
const int64 lowestPos = jmax ((int64) 0, pos - 1024); const int64 lowestPos = jmax ((int64) 0, pos - 1024);
char buffer [32];
zeromem (buffer, sizeof (buffer));
char buffer [32] = { 0 };
while (pos > lowestPos) while (pos > lowestPos)
{ {


+ 2
- 1
src/io/streams/juce_MemoryOutputStream.cpp View File

@@ -131,7 +131,8 @@ int MemoryOutputStream::writeFromInputStream (InputStream& source, int64 maxNumB
const String MemoryOutputStream::toUTF8() const const String MemoryOutputStream::toUTF8() const
{ {
return String::fromUTF8 (static_cast <const char*> (getData()), (int) getDataSize());
const char* const d = static_cast <const char*> (getData());
return String (CharPointer_UTF8 (d), CharPointer_UTF8 (d + getDataSize()));
} }
const String MemoryOutputStream::toString() const const String MemoryOutputStream::toString() const


+ 1
- 1
src/maths/juce_BigInteger.cpp View File

@@ -206,7 +206,7 @@ void BigInteger::clear()
} }
else else
{ {
zeromem (values, sizeof (uint32) * (numValues + 1));
values.clear (numValues + 1);
} }
highestBit = -1; highestBit = -1;


+ 8
- 0
src/memory/juce_HeapBlock.h View File

@@ -230,6 +230,14 @@ public:
swapVariables (data, other.data); swapVariables (data, other.data);
} }
/** This fills the block with zeros, up to the number of elements specified.
Since the block has no way of knowing its own size, you must make sure that the number of
elements you specify doesn't exceed the allocated size.
*/
void clear (size_t numElements) throw()
{
zeromem (data, sizeof (ElementType) * numElements);
}
private: private:
//============================================================================== //==============================================================================


+ 8
- 4
src/memory/juce_ReferenceCountedObject.h View File

@@ -113,12 +113,16 @@ private:
//============================================================================== //==============================================================================
/** /**
Used to point to an object of type ReferenceCountedObject.
A smart-pointer class which points to a reference-counted object.
It's wise to use a typedef instead of typing out the templated name
each time - e.g.
The template parameter specifies the class of the object you want to point to - the easiest
way to make a class reference-countable is to simply make it inherit from ReferenceCountedObject,
but if you need to, you could roll your own reference-countable class by implementing a pair of
mathods called incReferenceCount() and decReferenceCount().
typedef ReferenceCountedObjectPtr<MyClass> MyClassPtr;
When using this class, you'll probably want to create a typedef to abbreviate the full
templated name - e.g.
@code typedef ReferenceCountedObjectPtr<MyClass> MyClassPtr;@endcode
@see ReferenceCountedObject, ReferenceCountedObjectArray @see ReferenceCountedObject, ReferenceCountedObjectArray
*/ */


+ 1
- 1
src/native/android/juce_android_Files.cpp View File

@@ -195,7 +195,7 @@ public:
if (fnmatch (wildcardUTF8, de->d_name, FNM_CASEFOLD) == 0) if (fnmatch (wildcardUTF8, de->d_name, FNM_CASEFOLD) == 0)
{ {
filenameFound = String::fromUTF8 (de->d_name);
filenameFound = CharPointer_UTF8 (de->d_name);
updateStatInfoForFile (parentDir + filenameFound, isDir, fileSize, modTime, creationTime, isReadOnly); updateStatInfoForFile (parentDir + filenameFound, isDir, fileSize, modTime, creationTime, isReadOnly);


+ 1
- 1
src/native/android/juce_android_SystemStats.cpp View File

@@ -105,7 +105,7 @@ const String SystemStats::getLogonName()
user = pw->pw_name; user = pw->pw_name;
} }
return String::fromUTF8 (user);
return CharPointer_UTF8 (user);
} }
const String SystemStats::getFullUserName() const String SystemStats::getFullUserName()


+ 2
- 2
src/native/common/juce_posix_SharedCode.h View File

@@ -214,7 +214,7 @@ const File File::getCurrentWorkingDirectory()
bufferSize += 1024; bufferSize += 1024;
} }
return File (String::fromUTF8 (cwd));
return File (CharPointer_UTF8 (cwd));
} }
bool File::setAsCurrentWorkingDirectory() const bool File::setAsCurrentWorkingDirectory() const
@@ -490,7 +490,7 @@ const File juce_getExecutableFile()
#else #else
Dl_info exeInfo; Dl_info exeInfo;
dladdr ((void*) juce_getExecutableFile, &exeInfo); // (can't be a const void* on android) dladdr ((void*) juce_getExecutableFile, &exeInfo); // (can't be a const void* on android)
return File::getCurrentWorkingDirectory().getChildFile (String::fromUTF8 (exeInfo.dli_fname));
return File::getCurrentWorkingDirectory().getChildFile (CharPointer_UTF8 (exeInfo.dli_fname));
#endif #endif
} }


+ 3
- 3
src/native/linux/juce_linux_Files.cpp View File

@@ -150,7 +150,7 @@ const File File::getSpecialLocation (const SpecialLocationType type)
homeDir = pw->pw_dir; homeDir = pw->pw_dir;
} }
return File (String::fromUTF8 (homeDir));
return File (CharPointer_UTF8 (homeDir));
} }
case userDocumentsDirectory: case userDocumentsDirectory:
@@ -185,7 +185,7 @@ const File File::getSpecialLocation (const SpecialLocationType type)
case invokedExecutableFile: case invokedExecutableFile:
if (juce_Argv0 != 0) if (juce_Argv0 != 0)
return File (String::fromUTF8 (juce_Argv0));
return File (CharPointer_UTF8 (juce_Argv0));
// deliberate fall-through... // deliberate fall-through...
case currentExecutableFile: case currentExecutableFile:
@@ -260,7 +260,7 @@ public:
if (fnmatch (wildcardUTF8, de->d_name, FNM_CASEFOLD) == 0) if (fnmatch (wildcardUTF8, de->d_name, FNM_CASEFOLD) == 0)
{ {
filenameFound = String::fromUTF8 (de->d_name);
filenameFound = CharPointer_UTF8 (de->d_name);
updateStatInfoForFile (parentDir + filenameFound, isDir, fileSize, modTime, creationTime, isReadOnly); updateStatInfoForFile (parentDir + filenameFound, isDir, fileSize, modTime, creationTime, isReadOnly);


+ 1
- 1
src/native/linux/juce_linux_Fonts.cpp View File

@@ -103,7 +103,7 @@ public:
} }
StringArray fontDirs; StringArray fontDirs;
fontDirs.addTokens (String::fromUTF8 (getenv ("JUCE_FONT_PATH")), ";,", String::empty);
fontDirs.addTokens (CharPointer_UTF8 (getenv ("JUCE_FONT_PATH")), ";,", String::empty);
fontDirs.removeEmptyStrings (true); fontDirs.removeEmptyStrings (true);
if (fontDirs.size() == 0) if (fontDirs.size() == 0)


+ 1
- 1
src/native/linux/juce_linux_Network.cpp View File

@@ -329,7 +329,7 @@ private:
numConsecutiveLFs = 0; numConsecutiveLFs = 0;
} }
const String header (String::fromUTF8 ((const char*) buffer.getData()));
const String header (CharPointer_UTF8 ((const char*) buffer.getData()));
if (header.startsWithIgnoreCase ("HTTP/")) if (header.startsWithIgnoreCase ("HTTP/"))
return header.trimEnd(); return header.trimEnd();


+ 1
- 1
src/native/linux/juce_linux_SystemStats.cpp View File

@@ -108,7 +108,7 @@ const String SystemStats::getLogonName()
user = pw->pw_name; user = pw->pw_name;
} }
return String::fromUTF8 (user);
return CharPointer_UTF8 (user);
} }
const String SystemStats::getFullUserName() const String SystemStats::getFullUserName()


+ 1
- 4
src/native/linux/juce_linux_Windowing.cpp View File

@@ -507,12 +507,9 @@ public:
if (! usingXShm) if (! usingXShm)
#endif #endif
{ {
imageDataAllocated.malloc (lineStride * h);
imageDataAllocated.allocate (lineStride * h, format_ == Image::ARGB && clearImage);
imageData = imageDataAllocated; imageData = imageDataAllocated;
if (format_ == Image::ARGB && clearImage)
zeromem (imageData, h * lineStride);
xImage = (XImage*) juce_calloc (sizeof (XImage)); xImage = (XImage*) juce_calloc (sizeof (XImage));
xImage->width = w; xImage->width = w;


+ 2
- 2
src/native/mac/juce_mac_AudioCDBurner.mm View File

@@ -172,7 +172,7 @@ END_JUCE_NAMESPACE
if ([err length] > 0) if ([err length] > 0)
{ {
*error = JUCE_NAMESPACE::String::fromUTF8 ([err UTF8String]);
*error = JUCE_NAMESPACE::CharPointer_UTF8 ([err UTF8String]);
break; break;
} }
} }
@@ -482,7 +482,7 @@ const StringArray AudioCDBurner::findAvailableDevices()
StringArray s; StringArray s;
for (unsigned int i = 0; i < [names count]; ++i) for (unsigned int i = 0; i < [names count]; ++i)
s.add (String::fromUTF8 ([[names objectAtIndex: i] UTF8String]));
s.add (CharPointer_UTF8 ([[names objectAtIndex: i] UTF8String]));
return s; return s;
} }


+ 1
- 2
src/native/mac/juce_mac_CoreAudio.cpp View File

@@ -150,8 +150,7 @@ public:
String name; String name;
{ {
char channelName [256];
zerostruct (channelName);
char channelName [256] = { 0 };
UInt32 nameSize = sizeof (channelName); UInt32 nameSize = sizeof (channelName);
UInt32 channelNum = chanNum + 1; UInt32 channelNum = chanNum + 1;
pa.mSelector = kAudioDevicePropertyChannelName; pa.mSelector = kAudioDevicePropertyChannelName;


+ 3
- 4
src/native/mac/juce_mac_Files.mm View File

@@ -212,7 +212,7 @@ const File File::getSpecialLocation (const SpecialLocationType type)
case invokedExecutableFile: case invokedExecutableFile:
if (juce_Argv0 != 0) if (juce_Argv0 != 0)
return File (String::fromUTF8 (juce_Argv0));
return File (CharPointer_UTF8 (juce_Argv0));
// deliberate fall-through... // deliberate fall-through...
case currentExecutableFile: case currentExecutableFile:
@@ -449,11 +449,10 @@ bool PlatformUtilities::makeFSRefFromPath (FSRef* destFSRef, const String& path)
const String PlatformUtilities::makePathFromFSRef (FSRef* file) const String PlatformUtilities::makePathFromFSRef (FSRef* file)
{ {
char path [2048];
zerostruct (path);
char path [2048] = { 0 };
if (FSRefMakePath (file, (UInt8*) path, sizeof (path) - 1) == noErr) if (FSRefMakePath (file, (UInt8*) path, sizeof (path) - 1) == noErr)
return PlatformUtilities::convertToPrecomposedUnicode (String::fromUTF8 (path));
return PlatformUtilities::convertToPrecomposedUnicode (CharPointer_UTF8 (path));
return String::empty; return String::empty;
} }


+ 1
- 1
src/native/mac/juce_mac_Strings.mm View File

@@ -32,7 +32,7 @@ namespace
{ {
const String nsStringToJuce (NSString* s) const String nsStringToJuce (NSString* s)
{ {
return String::fromUTF8 ([s UTF8String]);
return CharPointer_UTF8 ([s UTF8String]);
} }
NSString* juceStringToNS (const String& s) NSString* juceStringToNS (const String& s)


+ 3
- 5
src/native/windows/juce_win32_ASIO.cpp View File

@@ -245,9 +245,8 @@ public:
if (sampleRate == 0) if (sampleRate == 0)
sampleRate = 44100; sampleRate = 44100;
long numSources = 32;
ASIOClockSource clocks[32];
zeromem (clocks, sizeof (clocks));
ASIOClockSource clocks[32] = { 0 };
long numSources = numElementsInArray (clocks);
asioObject->getClockSources (clocks, &numSources); asioObject->getClockSources (clocks, &numSources);
bool isSourceSet = false; bool isSourceSet = false;
@@ -842,8 +841,7 @@ private:
{ {
if (asioObject != 0) if (asioObject != 0)
{ {
char buffer [256];
zeromem (buffer, sizeof (buffer));
char buffer [256] = { 0 };
if (! asioObject->init (windowHandle)) if (! asioObject->init (windowHandle))
{ {


+ 2
- 3
src/native/windows/juce_win32_AudioCDReader.cpp View File

@@ -327,8 +327,7 @@ void findCDDevices (Array<CDDeviceDescription>& list)
if (h != INVALID_HANDLE_VALUE) if (h != INVALID_HANDLE_VALUE)
{ {
char buffer[100];
zeromem (buffer, sizeof (buffer));
char buffer[100] = { 0 };
SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER p; SCSI_PASS_THROUGH_DIRECT_WITH_BUFFER p;
zerostruct (p); zerostruct (p);
@@ -1688,7 +1687,7 @@ bool AudioCDBurner::addAudioTrack (AudioSource* audioSource, int numSamples)
source->getNextAudioBlock (info); source->getNextAudioBlock (info);
} }
zeromem (buffer, bytesPerBlock);
buffer.clear (bytesPerBlock);
typedef AudioData::Pointer <AudioData::Int16, AudioData::LittleEndian, typedef AudioData::Pointer <AudioData::Int16, AudioData::LittleEndian,
AudioData::Interleaved, AudioData::NonConst> CDSampleFormat; AudioData::Interleaved, AudioData::NonConst> CDSampleFormat;


+ 1
- 2
src/native/windows/juce_win32_OpenGLComponent.cpp View File

@@ -430,8 +430,7 @@ private:
if (availableExtensions.contains ("WGL_ARB_multisample")) if (availableExtensions.contains ("WGL_ARB_multisample"))
attributes[numAttributes++] = WGL_SAMPLES_ARB; attributes[numAttributes++] = WGL_SAMPLES_ARB;
int values[32];
zeromem (values, sizeof (values));
int values[32] = { 0 };
if (wglGetPixelFormatAttribivARB (dc, pixelFormatIndex, 0, numAttributes, attributes, values)) if (wglGetPixelFormatAttribivARB (dc, pixelFormatIndex, 0, numAttributes, attributes, values))
{ {


+ 1
- 2
src/native/windows/juce_win32_SystemStats.cpp View File

@@ -67,8 +67,7 @@ const String SystemStats::getCpuVendor()
static void juce_getCpuVendor (char* const v) static void juce_getCpuVendor (char* const v)
{ {
int vendor[4];
zeromem (vendor, 16);
int vendor[4] = { 0 };
#ifdef JUCE_64BIT #ifdef JUCE_64BIT
#else #else


+ 13
- 14
src/text/juce_String.cpp View File

@@ -2102,13 +2102,17 @@ const String String::createStringFromData (const void* const data_, const int si
} }
else else
{ {
const uint8* start = data;
const uint8* end = data + size;
if (size >= 3 if (size >= 3
&& data[0] == (uint8) CharPointer_UTF8::byteOrderMark1 && data[0] == (uint8) CharPointer_UTF8::byteOrderMark1
&& data[1] == (uint8) CharPointer_UTF8::byteOrderMark2 && data[1] == (uint8) CharPointer_UTF8::byteOrderMark2
&& data[2] == (uint8) CharPointer_UTF8::byteOrderMark3) && data[2] == (uint8) CharPointer_UTF8::byteOrderMark3)
return String::fromUTF8 ((const char*) data + 3, size - 3);
start += 3;
return String::fromUTF8 ((const char*) data, size);
return String (CharPointer_UTF8 ((const char*) start),
CharPointer_UTF8 ((const char*) end));
} }
} }
@@ -2218,18 +2222,13 @@ int String::getNumBytesAsUTF8() const throw()
const String String::fromUTF8 (const char* const buffer, int bufferSizeBytes) const String String::fromUTF8 (const char* const buffer, int bufferSizeBytes)
{ {
if (buffer == 0)
return empty;
CharPointer_UTF8 b (buffer);
if (bufferSizeBytes < 0)
return String (b);
const size_t numChars = b.lengthUpTo (CharPointer_UTF8 (buffer + bufferSizeBytes));
if (numChars > 0)
return String (b, numChars);
if (buffer != 0)
{
if (bufferSizeBytes < 0)
return String (CharPointer_UTF8 (buffer));
else if (bufferSizeBytes > 0)
return String (CharPointer_UTF8 (buffer), CharPointer_UTF8 (buffer + bufferSizeBytes));
}
return String::empty; return String::empty;
} }


Loading…
Cancel
Save