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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user