1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-07-04 22:49:07 +02:00

define freer

This commit is contained in:
Paul Licameli 2016-08-13 11:22:03 -04:00
parent 1eff721f09
commit 5ca8766c52

View File

@ -750,6 +750,23 @@ make_movable_with_deleter(const Deleter &d, Args&&... args)
return movable_ptr_with_deleter<T, Deleter>(safenew T(std::forward<Args>(args)...), d);
}
/*
* A deleter for pointers obtained with malloc
*/
struct freer { void operator() (void *p) const { free(p); } };
/*
* A useful alias for holding the result of malloc
*/
template< typename T >
using MallocPtr = std::unique_ptr< T, freer >;
/*
* A useful alias for holding the result of strup and similar
*/
template <typename Character = char>
using MallocString = std::unique_ptr< Character[], freer >;
/*
* A deleter class to supply the second template parameter of unique_ptr for
* classes like wxWindow that should be sent a message called Destroy rather