All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.lwjgl.system.jemalloc.MallocMessageCallback Maven / Gradle / Ivy

Go to download

A general purpose malloc implementation that emphasizes fragmentation avoidance and scalable concurrency support.

There is a newer version: 3.3.4
Show newest version
/*
 * Copyright LWJGL. All rights reserved.
 * License terms: https://www.lwjgl.org/license
 * MACHINE GENERATED FILE, DO NOT EDIT
 */
package org.lwjgl.system.jemalloc;

import org.lwjgl.system.*;

import static org.lwjgl.system.MemoryUtil.*;

/** Instances of this class may be passed to the {@link JEmalloc#je_malloc_usable_size malloc_usable_size} method. */
public abstract class MallocMessageCallback extends Callback implements MallocMessageCallbackI {

    /** Creates a {@code MallocMessageCallback} instance from the specified function pointer. */
    public static MallocMessageCallback create(long functionPointer) {
        if (functionPointer == NULL) {
            return null;
        }

        MallocMessageCallbackI instance = Callback.get(functionPointer);
        return instance instanceof MallocMessageCallback
            ? (MallocMessageCallback)instance
            : new Container(functionPointer, instance);
    }

    /** Creates a {@code MallocMessageCallback} instance that delegates to the specified {@code MallocMessageCallbackI} instance. */
    public static MallocMessageCallback create(MallocMessageCallbackI instance) {
        return instance instanceof MallocMessageCallback
            ? (MallocMessageCallback)instance
            : new Container(instance.address(), instance);
    }

    protected MallocMessageCallback() {
        super(SIGNATURE);
    }

    private MallocMessageCallback(long functionPointer) {
        super(functionPointer);
    }

    /**
     * Converts the specified {@link MallocMessageCallback} arguments to a String.
     *
     * 

This method may only be used inside a MallocMessageCallback invocation.

* * @param s the MallocMessageCallback {@code s} argument * * @return the message as a String */ public static String getMessage(long s) { return memASCII(s); } private static final class Container extends MallocMessageCallback { private final MallocMessageCallbackI delegate; Container(long functionPointer, MallocMessageCallbackI delegate) { super(functionPointer); this.delegate = delegate; } @Override public void invoke(long cbopaque, long s) { delegate.invoke(cbopaque, s); } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy