diff --git a/juce_amalgamated.cpp b/juce_amalgamated.cpp index a5243f3ec3..17f27b87c7 100644 --- a/juce_amalgamated.cpp +++ b/juce_amalgamated.cpp @@ -13154,31 +13154,28 @@ bool String::containsNonWhitespaceChars() const throw() return false; } -const String String::formatted (const String& pf, ... ) +// Note! The format parameter here MUST NOT be a reference, otherwise MS's va_start macro fails to work (but still compiles). +const String String::formatted (const String pf, ... ) { - va_list args; - va_start (args, pf); - size_t bufferSize = 256; for (;;) { - #if JUCE_LINUX && JUCE_64BIT - HeapBlock temp (bufferSize); - va_list tempArgs; - va_copy (tempArgs, args); - const int num = (int) vswprintf (temp.getData(), bufferSize - 1, pf.toUTF32(), tempArgs); - va_end (tempArgs); - #elif JUCE_WINDOWS + va_list args; + va_start (args, pf); + + #if JUCE_WINDOWS HeapBlock temp (bufferSize); - const int num = (int) _vsnwprintf (temp.getData(), bufferSize - 1, pf.toUTF16(), args); - #elif JUCE_ANDROID + const int num = (int) _vsnwprintf (temp.getData(), bufferSize - 1, pf.toWideCharPointer(), args); + #elif JUCE_ANDROID HeapBlock temp (bufferSize); const int num = (int) vsnprintf (temp.getData(), bufferSize - 1, pf.toUTF8(), args); - #else + #else HeapBlock temp (bufferSize); - const int num = (int) vswprintf (temp.getData(), bufferSize - 1, pf.toUTF32(), args); - #endif + const int num = (int) vswprintf (temp.getData(), bufferSize - 1, pf.toWideCharPointer(), args); + #endif + + va_end (args); if (num > 0) return String (temp); @@ -14587,8 +14584,7 @@ namespace XmlIdentifierChars /*static void generateIdentifierCharConstants() { - uint32 n[8]; - zerostruct (n); + uint32 n[8] = { 0 }; for (int i = 0; i < 256; ++i) if (isIdentifierCharSlow (i)) n[i >> 5] |= (1 << (i & 31)); @@ -15453,8 +15449,7 @@ namespace XmlOutputFunctions void generateLegalCharConstants() { - uint8 n[32]; - zerostruct (n); + uint8 n[32] = { 0 }; for (int i = 0; i < 256; ++i) if (isLegalXmlCharSlow (i)) n[i >> 3] |= (1 << (i & 7)); @@ -21054,8 +21049,7 @@ bool AudioFormatWriter::writeFromAudioReader (AudioFormatReader& reader, const int bufferSize = 16384; AudioSampleBuffer tempBuffer (numChannels, bufferSize); - int* buffers [128]; - zerostruct (buffers); + int* buffers [128] = { 0 }; for (int i = tempBuffer.getNumChannels(); --i >= 0;) buffers[i] = reinterpret_cast (tempBuffer.getSampleData (i, 0)); @@ -21084,7 +21078,7 @@ bool AudioFormatWriter::writeFromAudioReader (AudioFormatReader& reader, const double factor = 1.0 / std::numeric_limits::max(); for (int i = 0; i < numToDo; ++i) - ((float*) b)[i] = (float) (factor * b[i]); + reinterpret_cast (b)[i] = (float) (factor * b[i]); } else { @@ -33416,8 +33410,7 @@ public: desc.name = name; { - char buffer [512]; - zerostruct (buffer); + char buffer [512] = { 0 }; dispatch (effGetEffectName, 0, 0, buffer, 0); desc.descriptiveName = String (buffer).trim(); @@ -33433,8 +33426,7 @@ public: desc.category = getCategory(); { - char buffer [kVstMaxVendorStrLen + 8]; - zerostruct (buffer); + char buffer [kVstMaxVendorStrLen + 8] = { 0 }; dispatch (effGetVendorString, 0, 0, buffer, 0); desc.manufacturerName = buffer; } @@ -35165,8 +35157,7 @@ const String VSTPluginInstance::getParameterName (int index) { jassert (index >= 0 && index < effect->numParams); - char nm [256]; - zerostruct (nm); + char nm [256] = { 0 }; dispatch (effGetParamName, index, 0, nm, 0); return String (nm).trim(); } @@ -35180,8 +35171,7 @@ const String VSTPluginInstance::getParameterLabel (int index) const { jassert (index >= 0 && index < effect->numParams); - char nm [256]; - zerostruct (nm); + char nm [256] = { 0 }; dispatch (effGetParamLabel, index, 0, nm, 0); return String (nm).trim(); } @@ -35195,8 +35185,7 @@ const String VSTPluginInstance::getParameterText (int index) { jassert (index >= 0 && index < effect->numParams); - char nm [256]; - zerostruct (nm); + char nm [256] = { 0 }; dispatch (effGetParamDisplay, index, 0, nm, 0); return String (nm).trim(); } @@ -35250,8 +35239,7 @@ const String VSTPluginInstance::getProgramName (int index) } else if (effect != 0) { - char nm [256]; - zerostruct (nm); + char nm [256] = { 0 }; if (dispatch (effGetProgramNameIndexed, jlimit (0, getNumPrograms(), index), @@ -35281,8 +35269,7 @@ void VSTPluginInstance::updateStoredProgramNames() { if (effect != 0 && getNumPrograms() > 0) { - char nm [256]; - zerostruct (nm); + char nm [256] = { 0 }; // only do this if the plugin can't use indexed names.. if (dispatch (effGetProgramNameIndexed, 0, -1, nm, 0) == 0) @@ -35307,8 +35294,7 @@ const String VSTPluginInstance::getCurrentProgramName() { if (effect != 0) { - char nm [256]; - zerostruct (nm); + char nm [256] = { 0 }; dispatch (effGetProgramName, 0, 0, nm, 0); const int index = getCurrentProgram(); @@ -35448,11 +35434,9 @@ void VSTPluginFormat::findAllTypesForFile (OwnedArray & resul else { // It's a shell plugin, so iterate all the subtypes... - char shellEffectName [64]; - for (;;) { - zerostruct (shellEffectName); + char shellEffectName [64] = { 0 }; const int uid = instance->dispatch (effShellGetNextPlugin, 0, 0, shellEffectName, 0); if (uid == 0) @@ -242426,9 +242410,8 @@ int SystemStats::getPageSize() const String SystemStats::getLogonName() { - TCHAR text [256]; + TCHAR text [256] = { 0 }; DWORD len = numElementsInArray (text) - 2; - zerostruct (text); GetUserName (text, &len); return String (text, len); } @@ -248871,8 +248854,7 @@ namespace FileChooserHelpers if (comp != 0) { - WCHAR path [MAX_PATH * 2]; - zerostruct (path); + WCHAR path [MAX_PATH * 2] = { 0 }; CommDlg_OpenSave_GetFilePath (GetParent (hdlg), (LPARAM) &path, MAX_PATH); comp->selectedFileChanged (File (path)); @@ -254710,8 +254692,7 @@ private: if (RegOpenKeyEx (hk, keyName.toUTF16(), 0, KEY_READ, &subKey) == ERROR_SUCCESS) { - TCHAR buf [256]; - zerostruct (buf); + TCHAR buf [256] = { 0 }; DWORD dtype = REG_SZ; DWORD dsize = sizeof (buf); @@ -266948,11 +266929,11 @@ class MessageQueue public: MessageQueue() { - #if MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_4 && ! JUCE_IOS + #if MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_4 && ! JUCE_IOS runLoop = CFRunLoopGetMain(); - #else + #else runLoop = CFRunLoopGetCurrent(); - #endif + #endif CFRunLoopSourceContext sourceContext; zerostruct (sourceContext); @@ -267262,13 +267243,13 @@ int PlatformUtilities::getOSXMinorVersionNumber() bool SystemStats::isOperatingSystem64Bit() { -#if JUCE_IOS + #if JUCE_IOS return false; -#elif JUCE_64BIT + #elif JUCE_64BIT return true; -#else + #else return PlatformUtilities::getOSXMinorVersionNumber() >= 6; -#endif + #endif } int SystemStats::getMemorySizeInMegabytes() @@ -267282,17 +267263,16 @@ int SystemStats::getMemorySizeInMegabytes() const String SystemStats::getCpuVendor() { -#if JUCE_INTEL + #if JUCE_INTEL uint32 dummy = 0; - uint32 vendor[4]; - zerostruct (vendor); + uint32 vendor[4] = { 0 }; SystemStatsHelpers::doCPUID (dummy, vendor[0], vendor[2], vendor[1], 0); return String (reinterpret_cast (vendor), 12); -#else + #else return String::empty; -#endif + #endif } int SystemStats::getCpuSpeedInMegaherz() @@ -267302,10 +267282,11 @@ int SystemStats::getCpuSpeedInMegaherz() int mib[] = { CTL_HW, HW_CPU_FREQ }; sysctl (mib, 2, &speedHz, &speedSize, 0, 0); -#if JUCE_BIG_ENDIAN + #if JUCE_BIG_ENDIAN if (speedSize == 4) speedHz >>= 32; -#endif + #endif + return (int) (speedHz / 1000000); } diff --git a/juce_amalgamated.h b/juce_amalgamated.h index 2dd7d875d7..4ff32233a7 100644 --- a/juce_amalgamated.h +++ b/juce_amalgamated.h @@ -73,7 +73,7 @@ namespace JuceDummyNamespace {} */ #define JUCE_MAJOR_VERSION 1 #define JUCE_MINOR_VERSION 53 -#define JUCE_BUILDNUMBER 47 +#define JUCE_BUILDNUMBER 48 /** Current Juce version number. @@ -5012,7 +5012,7 @@ public: on the platform, it may be using wchar_t or char character types, so that even string literals can't be safely used as parameters if you're writing portable code. */ - static const String formatted (const String& formatString, ... ); + static const String formatted (const String formatString, ... ); // Numeric conversions.. diff --git a/src/audio/audio_file_formats/juce_AudioFormatWriter.cpp b/src/audio/audio_file_formats/juce_AudioFormatWriter.cpp index e3b98f445a..897466ac19 100644 --- a/src/audio/audio_file_formats/juce_AudioFormatWriter.cpp +++ b/src/audio/audio_file_formats/juce_AudioFormatWriter.cpp @@ -60,8 +60,7 @@ bool AudioFormatWriter::writeFromAudioReader (AudioFormatReader& reader, const int bufferSize = 16384; AudioSampleBuffer tempBuffer (numChannels, bufferSize); - int* buffers [128]; - zerostruct (buffers); + int* buffers [128] = { 0 }; for (int i = tempBuffer.getNumChannels(); --i >= 0;) buffers[i] = reinterpret_cast (tempBuffer.getSampleData (i, 0)); @@ -90,7 +89,7 @@ bool AudioFormatWriter::writeFromAudioReader (AudioFormatReader& reader, const double factor = 1.0 / std::numeric_limits::max(); for (int i = 0; i < numToDo; ++i) - ((float*) b)[i] = (float) (factor * b[i]); + reinterpret_cast (b)[i] = (float) (factor * b[i]); } else { diff --git a/src/audio/plugins/formats/juce_VSTPluginFormat.cpp b/src/audio/plugins/formats/juce_VSTPluginFormat.cpp index 66b93cc4bd..bdfddfa374 100644 --- a/src/audio/plugins/formats/juce_VSTPluginFormat.cpp +++ b/src/audio/plugins/formats/juce_VSTPluginFormat.cpp @@ -708,8 +708,7 @@ public: desc.name = name; { - char buffer [512]; - zerostruct (buffer); + char buffer [512] = { 0 }; dispatch (effGetEffectName, 0, 0, buffer, 0); desc.descriptiveName = String (buffer).trim(); @@ -725,8 +724,7 @@ public: desc.category = getCategory(); { - char buffer [kVstMaxVendorStrLen + 8]; - zerostruct (buffer); + char buffer [kVstMaxVendorStrLen + 8] = { 0 }; dispatch (effGetVendorString, 0, 0, buffer, 0); desc.manufacturerName = buffer; } @@ -2489,8 +2487,7 @@ const String VSTPluginInstance::getParameterName (int index) { jassert (index >= 0 && index < effect->numParams); - char nm [256]; - zerostruct (nm); + char nm [256] = { 0 }; dispatch (effGetParamName, index, 0, nm, 0); return String (nm).trim(); } @@ -2504,8 +2501,7 @@ const String VSTPluginInstance::getParameterLabel (int index) const { jassert (index >= 0 && index < effect->numParams); - char nm [256]; - zerostruct (nm); + char nm [256] = { 0 }; dispatch (effGetParamLabel, index, 0, nm, 0); return String (nm).trim(); } @@ -2519,8 +2515,7 @@ const String VSTPluginInstance::getParameterText (int index) { jassert (index >= 0 && index < effect->numParams); - char nm [256]; - zerostruct (nm); + char nm [256] = { 0 }; dispatch (effGetParamDisplay, index, 0, nm, 0); return String (nm).trim(); } @@ -2575,8 +2570,7 @@ const String VSTPluginInstance::getProgramName (int index) } else if (effect != 0) { - char nm [256]; - zerostruct (nm); + char nm [256] = { 0 }; if (dispatch (effGetProgramNameIndexed, jlimit (0, getNumPrograms(), index), @@ -2606,8 +2600,7 @@ void VSTPluginInstance::updateStoredProgramNames() { if (effect != 0 && getNumPrograms() > 0) { - char nm [256]; - zerostruct (nm); + char nm [256] = { 0 }; // only do this if the plugin can't use indexed names.. if (dispatch (effGetProgramNameIndexed, 0, -1, nm, 0) == 0) @@ -2632,8 +2625,7 @@ const String VSTPluginInstance::getCurrentProgramName() { if (effect != 0) { - char nm [256]; - zerostruct (nm); + char nm [256] = { 0 }; dispatch (effGetProgramName, 0, 0, nm, 0); const int index = getCurrentProgram(); @@ -2778,11 +2770,9 @@ void VSTPluginFormat::findAllTypesForFile (OwnedArray & resul else { // It's a shell plugin, so iterate all the subtypes... - char shellEffectName [64]; - for (;;) { - zerostruct (shellEffectName); + char shellEffectName [64] = { 0 }; const int uid = instance->dispatch (effShellGetNextPlugin, 0, 0, shellEffectName, 0); if (uid == 0) diff --git a/src/core/juce_StandardHeader.h b/src/core/juce_StandardHeader.h index c626276a0c..42bb1f4bcc 100644 --- a/src/core/juce_StandardHeader.h +++ b/src/core/juce_StandardHeader.h @@ -33,7 +33,7 @@ */ #define JUCE_MAJOR_VERSION 1 #define JUCE_MINOR_VERSION 53 -#define JUCE_BUILDNUMBER 47 +#define JUCE_BUILDNUMBER 48 /** Current Juce version number. diff --git a/src/native/mac/juce_mac_NativeCode.mm b/src/native/mac/juce_mac_NativeCode.mm index f5b9453376..f065dba06d 100644 --- a/src/native/mac/juce_mac_NativeCode.mm +++ b/src/native/mac/juce_mac_NativeCode.mm @@ -124,11 +124,11 @@ class MessageQueue public: MessageQueue() { - #if MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_4 && ! JUCE_IOS + #if MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_4 && ! JUCE_IOS runLoop = CFRunLoopGetMain(); - #else + #else runLoop = CFRunLoopGetCurrent(); - #endif + #endif CFRunLoopSourceContext sourceContext; zerostruct (sourceContext); diff --git a/src/native/mac/juce_mac_SystemStats.mm b/src/native/mac/juce_mac_SystemStats.mm index 6701a88a75..ab129a1ac7 100644 --- a/src/native/mac/juce_mac_SystemStats.mm +++ b/src/native/mac/juce_mac_SystemStats.mm @@ -124,13 +124,13 @@ int PlatformUtilities::getOSXMinorVersionNumber() bool SystemStats::isOperatingSystem64Bit() { -#if JUCE_IOS + #if JUCE_IOS return false; -#elif JUCE_64BIT + #elif JUCE_64BIT return true; -#else + #else return PlatformUtilities::getOSXMinorVersionNumber() >= 6; -#endif + #endif } int SystemStats::getMemorySizeInMegabytes() @@ -144,17 +144,16 @@ int SystemStats::getMemorySizeInMegabytes() const String SystemStats::getCpuVendor() { -#if JUCE_INTEL + #if JUCE_INTEL uint32 dummy = 0; - uint32 vendor[4]; - zerostruct (vendor); + uint32 vendor[4] = { 0 }; SystemStatsHelpers::doCPUID (dummy, vendor[0], vendor[2], vendor[1], 0); return String (reinterpret_cast (vendor), 12); -#else + #else return String::empty; -#endif + #endif } int SystemStats::getCpuSpeedInMegaherz() @@ -164,10 +163,11 @@ int SystemStats::getCpuSpeedInMegaherz() int mib[] = { CTL_HW, HW_CPU_FREQ }; sysctl (mib, 2, &speedHz, &speedSize, 0, 0); -#if JUCE_BIG_ENDIAN + #if JUCE_BIG_ENDIAN if (speedSize == 4) speedHz >>= 32; -#endif + #endif + return (int) (speedHz / 1000000); } diff --git a/src/native/windows/juce_win32_ASIO.cpp b/src/native/windows/juce_win32_ASIO.cpp index 137aa808bf..b24d650c59 100644 --- a/src/native/windows/juce_win32_ASIO.cpp +++ b/src/native/windows/juce_win32_ASIO.cpp @@ -1801,8 +1801,7 @@ private: if (RegOpenKeyEx (hk, keyName.toUTF16(), 0, KEY_READ, &subKey) == ERROR_SUCCESS) { - TCHAR buf [256]; - zerostruct (buf); + TCHAR buf [256] = { 0 }; DWORD dtype = REG_SZ; DWORD dsize = sizeof (buf); diff --git a/src/native/windows/juce_win32_FileChooser.cpp b/src/native/windows/juce_win32_FileChooser.cpp index 4380129c5f..7d1f9d076b 100644 --- a/src/native/windows/juce_win32_FileChooser.cpp +++ b/src/native/windows/juce_win32_FileChooser.cpp @@ -100,8 +100,7 @@ namespace FileChooserHelpers if (comp != 0) { - WCHAR path [MAX_PATH * 2]; - zerostruct (path); + WCHAR path [MAX_PATH * 2] = { 0 }; CommDlg_OpenSave_GetFilePath (GetParent (hdlg), (LPARAM) &path, MAX_PATH); comp->selectedFileChanged (File (path)); diff --git a/src/native/windows/juce_win32_SystemStats.cpp b/src/native/windows/juce_win32_SystemStats.cpp index e7c59efc2a..f27cc60215 100644 --- a/src/native/windows/juce_win32_SystemStats.cpp +++ b/src/native/windows/juce_win32_SystemStats.cpp @@ -344,9 +344,8 @@ int SystemStats::getPageSize() //============================================================================== const String SystemStats::getLogonName() { - TCHAR text [256]; + TCHAR text [256] = { 0 }; DWORD len = numElementsInArray (text) - 2; - zerostruct (text); GetUserName (text, &len); return String (text, len); } diff --git a/src/text/juce_String.cpp b/src/text/juce_String.cpp index ccb9a0250d..b6e231aa03 100644 --- a/src/text/juce_String.cpp +++ b/src/text/juce_String.cpp @@ -1823,31 +1823,28 @@ bool String::containsNonWhitespaceChars() const throw() return false; } -const String String::formatted (const String& pf, ... ) +// Note! The format parameter here MUST NOT be a reference, otherwise MS's va_start macro fails to work (but still compiles). +const String String::formatted (const String pf, ... ) { - va_list args; - va_start (args, pf); - size_t bufferSize = 256; for (;;) { - #if JUCE_LINUX && JUCE_64BIT - HeapBlock temp (bufferSize); - va_list tempArgs; - va_copy (tempArgs, args); - const int num = (int) vswprintf (temp.getData(), bufferSize - 1, pf.toUTF32(), tempArgs); - va_end (tempArgs); - #elif JUCE_WINDOWS + va_list args; + va_start (args, pf); + + #if JUCE_WINDOWS HeapBlock temp (bufferSize); - const int num = (int) _vsnwprintf (temp.getData(), bufferSize - 1, pf.toUTF16(), args); - #elif JUCE_ANDROID + const int num = (int) _vsnwprintf (temp.getData(), bufferSize - 1, pf.toWideCharPointer(), args); + #elif JUCE_ANDROID HeapBlock temp (bufferSize); const int num = (int) vsnprintf (temp.getData(), bufferSize - 1, pf.toUTF8(), args); - #else + #else HeapBlock temp (bufferSize); - const int num = (int) vswprintf (temp.getData(), bufferSize - 1, pf.toUTF32(), args); - #endif + const int num = (int) vswprintf (temp.getData(), bufferSize - 1, pf.toWideCharPointer(), args); + #endif + + va_end (args); if (num > 0) return String (temp); diff --git a/src/text/juce_String.h b/src/text/juce_String.h index be5d113614..6d9c78c351 100644 --- a/src/text/juce_String.h +++ b/src/text/juce_String.h @@ -878,7 +878,7 @@ public: on the platform, it may be using wchar_t or char character types, so that even string literals can't be safely used as parameters if you're writing portable code. */ - static const String formatted (const String& formatString, ... ); + static const String formatted (const String formatString, ... ); //============================================================================== // Numeric conversions.. diff --git a/src/text/juce_XmlDocument.cpp b/src/text/juce_XmlDocument.cpp index 29d27f6d32..6cd3467039 100644 --- a/src/text/juce_XmlDocument.cpp +++ b/src/text/juce_XmlDocument.cpp @@ -91,8 +91,7 @@ namespace XmlIdentifierChars /*static void generateIdentifierCharConstants() { - uint32 n[8]; - zerostruct (n); + uint32 n[8] = { 0 }; for (int i = 0; i < 256; ++i) if (isIdentifierCharSlow (i)) n[i >> 5] |= (1 << (i & 31)); diff --git a/src/text/juce_XmlElement.cpp b/src/text/juce_XmlElement.cpp index 47edebbf59..7fbd5c5fbe 100644 --- a/src/text/juce_XmlElement.cpp +++ b/src/text/juce_XmlElement.cpp @@ -132,8 +132,7 @@ namespace XmlOutputFunctions void generateLegalCharConstants() { - uint8 n[32]; - zerostruct (n); + uint8 n[32] = { 0 }; for (int i = 0; i < 256; ++i) if (isLegalXmlCharSlow (i)) n[i >> 3] |= (1 << (i & 7));