1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-25 07:43:54 +02:00

Remove naked malloc (or similar) and free in: various

This commit is contained in:
Paul Licameli
2017-02-25 18:13:05 -05:00
parent cab99f7234
commit 1126925438
11 changed files with 44 additions and 56 deletions

View File

@@ -49,10 +49,6 @@ const wxChar *GetSampleFormatStr(sampleFormat format);
// Allocating/Freeing Samples
//
AUDACITY_DLL_API samplePtr NewSamples(size_t count, sampleFormat format);
AUDACITY_DLL_API void DeleteSamples(samplePtr p);
// RAII version of above
class SampleBuffer {
public:
@@ -60,7 +56,7 @@ public:
: mPtr(0)
{}
SampleBuffer(size_t count, sampleFormat format)
: mPtr(NewSamples(count, format))
: mPtr((samplePtr)malloc(count * SAMPLE_SIZE(format)))
{}
~SampleBuffer()
{
@@ -71,14 +67,14 @@ public:
SampleBuffer &Allocate(size_t count, sampleFormat format)
{
Free();
mPtr = NewSamples(count, format);
mPtr = (samplePtr)malloc(count * SAMPLE_SIZE(format));
return *this;
}
void Free()
{
DeleteSamples(mPtr);
free(mPtr);
mPtr = 0;
}