"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Pointer = void 0;
const image_magick_1 = require("../image-magick");
class Pointer {
    constructor() {
        this.instance = image_magick_1.ImageMagick._api._malloc(8);
        image_magick_1.ImageMagick._api.setValue(this.instance, 0, "i64");
    }
    get ptr() { return this.instance; }
    get value() { return image_magick_1.ImageMagick._api.getValue(this.instance, "i64"); }
    static use(func) {
        const pointer = new Pointer();
        try {
            return func(pointer);
        }
        finally {
            image_magick_1.ImageMagick._api._free(pointer.instance);
        }
    }
}
exports.Pointer = Pointer;
