Merge "media: Silence an analyzer complaint; clean up code"

This commit is contained in:
TreeHugger Robot
2019-01-30 22:56:09 +00:00
committed by Android (Google) Code Review
2 changed files with 6 additions and 2 deletions

View File

@@ -135,7 +135,7 @@ JNIAudioAttributeHelper::UniqueAaPtr JNIAudioAttributeHelper::makeUnique()
{
audio_attributes_t *aa = new (calloc(1, sizeof(audio_attributes_t)))
audio_attributes_t{AUDIO_ATTRIBUTES_INITIALIZER};
return UniqueAaPtr{aa, free};
return UniqueAaPtr{aa};
}
jint JNIAudioAttributeHelper::nativeFromJava(JNIEnv* env, jobject jAudioAttributes,

View File

@@ -27,7 +27,11 @@ namespace android {
class JNIAudioAttributeHelper
{
public:
using UniqueAaPtr = std::unique_ptr<audio_attributes_t, decltype(free)*>;
struct FreeDeleter {
void operator()(void *p) const { ::free(p); }
};
using UniqueAaPtr = std::unique_ptr<audio_attributes_t, FreeDeleter>;
/**
* @brief makeUnique helper to prevent leak