Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0bd6c6bf authored by Eric Miao's avatar Eric Miao
Browse files

Add missing method NativeAllocationRegistry.createMalloced(Class,long)

Method NativeAllocationRegistry.createMalloced(Class, long) was missing
in Ravenwood libcore-fake. ag/34933001 failed ravenwood test because of
this, see b/441804951.

This CL added the missing method.

Bug: b/441804951
Flag: EXEMPT bugfix
Test: submit ravenwood test with ag/34933001 which revealed the bug
Change-Id: Idb95db2fdfc974841f850b8e38f64cc720a1bd44
parent 1e25b062
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import java.lang.ref.Reference;
public class NativeAllocationRegistry {
    private final long mFreeFunction;
    private static final Cleaner sCleaner = Cleaner.create();
    private static final long DEFAULT_SIZE = 98;

    public static NativeAllocationRegistry createNonmalloced(
            ClassLoader classLoader, long freeFunction, long size) {
@@ -55,6 +56,11 @@ public class NativeAllocationRegistry {
        return new NativeAllocationRegistry(clazz.getClassLoader(), freeFunction, size);
    }

    public static NativeAllocationRegistry createMalloced(
            Class clazz, long freeFunction) {
        return new NativeAllocationRegistry(clazz.getClassLoader(), freeFunction, DEFAULT_SIZE);
    }

    public NativeAllocationRegistry(ClassLoader classLoader, long freeFunction, long size) {
        if (size < 0) {
            throw new IllegalArgumentException("Invalid native allocation size: " + size);