xref: /aosp_15_r20/external/skia/tools/AutoreleasePool.mm (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1/*
2 * Copyright 2019 Google LLC
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#include "include/core/SkTypes.h"
9#include "tools/AutoreleasePool.h"
10
11#import <Foundation/NSAutoreleasePool.h>
12
13AutoreleasePool::AutoreleasePool() {
14    fPool = (void*)[[NSAutoreleasePool alloc] init];
15}
16
17AutoreleasePool::~AutoreleasePool() {
18    [(NSAutoreleasePool*)fPool release];
19    fPool = nullptr;
20}
21
22void AutoreleasePool::drain() {
23    [(NSAutoreleasePool*)fPool drain];
24    fPool = (void*)[[NSAutoreleasePool alloc] init];
25}
26