blob: da06655ef0e3f21ad97decce7a7e52920f984a3c [file] [log] [blame]
Andreas Gamped299c072017-10-17 10:50:00 -07001/*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Orion Hodsonce487362020-04-22 19:41:46 +010017#pragma once
Andreas Gamped299c072017-10-17 10:50:00 -070018
Orion Hodson6d7238a2020-04-21 11:12:46 +010019#include <jni.h>
20
Orion Hodsonaadb3732018-11-21 12:58:34 +000021#include "nativehelper_utils.h"
Andreas Gamped299c072017-10-17 10:50:00 -070022
23class ScopedLocalFrame {
24public:
25 explicit ScopedLocalFrame(JNIEnv* env) : mEnv(env) {
26 mEnv->PushLocalFrame(128);
27 }
28
29 ~ScopedLocalFrame() {
Orion Hodson6d7238a2020-04-21 11:12:46 +010030 mEnv->PopLocalFrame(nullptr);
Andreas Gamped299c072017-10-17 10:50:00 -070031 }
32
33private:
34 JNIEnv* const mEnv;
35
36 DISALLOW_COPY_AND_ASSIGN(ScopedLocalFrame);
37};
38