<commit_before>// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterCallbackCache_Internal.h"

#include "flutter/lib/ui/plugins/callback_cache.h"

@implementation FlutterCallbackInformation
@end

@implementation FlutterCallbackCache

+ (FlutterCallbackInformation*)lookupCallbackInformation:(int64_t)handle {
  auto info = flutter::DartCallbackCache::GetCallbackInformation(handle);
  if (info == nullptr) {
    return nil;
  }
  FlutterCallbackInformation* new_info = [[FlutterCallbackInformation alloc] init];
  new_info.callbackName = [NSString stringWithUTF8String:info->name.c_str()];
  new_info.callbackClassName = [NSString stringWithUTF8String:info->class_name.c_str()];
  new_info.callbackLibraryPath = [NSString stringWithUTF8String:info->library_path.c_str()];
  return new_info;
}

+ (void)setCachePath:(NSString*)path {
  assert(path != nil);
  flutter::DartCallbackCache::SetCachePath([path UTF8String]);
  NSString* cache_path =
      [NSString stringWithUTF8String:flutter::DartCallbackCache::GetCachePath().c_str()];
  // Set the "Do Not Backup" flag to ensure that the cache isn't moved off disk in
  // low-memory situations.
  if (![[NSFileManager defaultManager] fileExistsAtPath:cache_path]) {
    [[NSFileManager defaultManager] createFileAtPath:cache_path contents:nil attributes:nil];
    NSError* error = nil;
    NSURL* URL = [NSURL fileURLWithPath:cache_path];
    BOOL success = [URL setResourceValue:[NSNumber numberWithBool:YES]
                                  forKey:NSURLIsExcludedFromBackupKey
                                   error:&error];
    if (!success) {
      NSLog(@"Error excluding %@ from backup %@", [URL lastPathComponent], error);
    }
  }
}

@end<commit_msg>Fixes FlutterCallbackInfomation leaks (#15089)<commit_after>// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterCallbackCache_Internal.h"

#include "flutter/lib/ui/plugins/callback_cache.h"

@implementation FlutterCallbackInformation
@end

@implementation FlutterCallbackCache

+ (FlutterCallbackInformation*)lookupCallbackInformation:(int64_t)handle {
  auto info = flutter::DartCallbackCache::GetCallbackInformation(handle);
  if (info == nullptr) {
    return nil;
  }
  FlutterCallbackInformation* new_info = [[[FlutterCallbackInformation alloc] init] autorelease];
  new_info.callbackName = [NSString stringWithUTF8String:info->name.c_str()];
  new_info.callbackClassName = [NSString stringWithUTF8String:info->class_name.c_str()];
  new_info.callbackLibraryPath = [NSString stringWithUTF8String:info->library_path.c_str()];
  return new_info;
}

+ (void)setCachePath:(NSString*)path {
  assert(path != nil);
  flutter::DartCallbackCache::SetCachePath([path UTF8String]);
  NSString* cache_path =
      [NSString stringWithUTF8String:flutter::DartCallbackCache::GetCachePath().c_str()];
  // Set the "Do Not Backup" flag to ensure that the cache isn't moved off disk in
  // low-memory situations.
  if (![[NSFileManager defaultManager] fileExistsAtPath:cache_path]) {
    [[NSFileManager defaultManager] createFileAtPath:cache_path contents:nil attributes:nil];
    NSError* error = nil;
    NSURL* URL = [NSURL fileURLWithPath:cache_path];
    BOOL success = [URL setResourceValue:[NSNumber numberWithBool:YES]
                                  forKey:NSURLIsExcludedFromBackupKey
                                   error:&error];
    if (!success) {
      NSLog(@"Error excluding %@ from backup %@", [URL lastPathComponent], error);
    }
  }
}

@end
{'fraction_non_alphanumeric': 0.10838338991903891, 'fraction_numerical': 0.00705144946461217, 'mean_word_length': 4.674074074074074, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '981746', 'n_tokens_mistral': 1165, 'n_tokens_neox': 1109, 'n_words': 247}