@JRubyMethod(name = "free") public final IRubyObject free(ThreadContext context) { ((AllocatedDirectMemoryIO) getMemoryIO()).free(); // Replace memory object with one that throws an exception on any access setMemoryIO(new FreedMemoryIO(context.runtime)); return context.nil; }
@JRubyMethod(name = "free") public final IRubyObject free(ThreadContext context) { ((AllocatedDirectMemoryIO) getMemoryIO()).free(); // Replace memory object with one that throws an exception on any access setMemoryIO(new FreedMemoryIO(context.runtime)); return context.nil; }
@JRubyMethod(name = "free") public final IRubyObject free(ThreadContext context) { ((AllocatedDirectMemoryIO) getMemoryIO()).free(); // Replace memory object with one that throws an exception on any access setMemoryIO(new FreedMemoryIO(context.runtime)); return context.runtime.getNil(); }
@JRubyMethod(name = "free") public final IRubyObject free(ThreadContext context) { ((AllocatedDirectMemoryIO) getMemoryIO()).free(); // Replace memory object with one that throws an exception on any access setMemoryIO(new FreedMemoryIO(context.runtime)); return context.runtime.getNil(); }
@JRubyMethod(name = "free") public final IRubyObject free(ThreadContext context) { if (getMemoryIO() instanceof AllocatedDirectMemoryIO) { ((AllocatedDirectMemoryIO) getMemoryIO()).free(); } else { throw context.runtime.newRuntimeError("cannot free non-allocated function"); } // Replace memory object with one that throws an exception on any access setMemoryIO(new FreedMemoryIO(context.runtime)); return context.nil; }
@JRubyMethod(name = "free") public final IRubyObject free(ThreadContext context) { if (getMemoryIO() instanceof AllocatedDirectMemoryIO) { ((AllocatedDirectMemoryIO) getMemoryIO()).free(); } else { throw context.runtime.newRuntimeError("cannot free non-allocated function"); } // Replace memory object with one that throws an exception on any access setMemoryIO(new FreedMemoryIO(context.runtime)); return context.nil; }
@JRubyMethod(name = "free") public final IRubyObject free(ThreadContext context) { if (getMemoryIO() instanceof AllocatedDirectMemoryIO) { ((AllocatedDirectMemoryIO) getMemoryIO()).free(); } else { throw context.runtime.newRuntimeError("cannot free non-allocated function"); } // Replace memory object with one that throws an exception on any access setMemoryIO(new FreedMemoryIO(context.runtime)); return context.runtime.getNil(); }
@JRubyMethod(name = "free") public final IRubyObject free(ThreadContext context) { if (getMemoryIO() instanceof AllocatedDirectMemoryIO) { ((AllocatedDirectMemoryIO) getMemoryIO()).free(); } else { throw context.runtime.newRuntimeError("cannot free non-allocated function"); } // Replace memory object with one that throws an exception on any access setMemoryIO(new FreedMemoryIO(context.runtime)); return context.runtime.getNil(); }
private final IRubyObject init(ThreadContext context, IRubyObject rbTypeSize, int count, int align, boolean clear, Block block) { typeSize = calculateTypeSize(context, rbTypeSize); size = typeSize * count; if (size < 0) { throw context.runtime.newArgumentError(String.format("Negative size (%d objects of %d size)", count, typeSize)); } setMemoryIO(Factory.getInstance().allocateDirectMemory(context.runtime, size > 0 ? (int) size : 1, align, clear)); if (getMemoryIO() == null) { Ruby runtime = context.runtime; throw RaiseException.from(runtime, runtime.getNoMemoryError(), String.format("Failed to allocate %d objects of %d bytes", typeSize, count)); } if (block.isGiven()) { try { return block.yield(context, this); } finally { ((AllocatedDirectMemoryIO) getMemoryIO()).free(); setMemoryIO(new FreedMemoryIO(context.runtime)); } } else { return this; } }
private final IRubyObject init(ThreadContext context, IRubyObject rbTypeSize, int count, int align, boolean clear, Block block) { typeSize = calculateTypeSize(context, rbTypeSize); size = typeSize * count; if (size < 0) { throw context.runtime.newArgumentError(String.format("Negative size (%d objects of %d size)", count, typeSize)); } setMemoryIO(Factory.getInstance().allocateDirectMemory(context.runtime, size > 0 ? (int) size : 1, align, clear)); if (getMemoryIO() == null) { Ruby runtime = context.runtime; throw new RaiseException(runtime, runtime.getNoMemoryError(), String.format("Failed to allocate %d objects of %d bytes", typeSize, count), true); } if (block.isGiven()) { try { return block.yield(context, this); } finally { ((AllocatedDirectMemoryIO) getMemoryIO()).free(); setMemoryIO(new FreedMemoryIO(context.runtime)); } } else { return this; } }
private final IRubyObject init(ThreadContext context, IRubyObject rbTypeSize, int count, int align, boolean clear, Block block) { typeSize = calculateTypeSize(context, rbTypeSize); size = typeSize * count; if (size < 0) { throw context.runtime.newArgumentError(String.format("Negative size (%d objects of %d size)", count, typeSize)); } setMemoryIO(Factory.getInstance().allocateDirectMemory(context.runtime, size > 0 ? (int) size : 1, align, clear)); if (getMemoryIO() == null) { Ruby runtime = context.runtime; throw RaiseException.from(runtime, runtime.getNoMemoryError(), String.format("Failed to allocate %d objects of %d bytes", typeSize, count)); } if (block.isGiven()) { try { return block.yield(context, this); } finally { ((AllocatedDirectMemoryIO) getMemoryIO()).free(); setMemoryIO(new FreedMemoryIO(context.runtime)); } } else { return this; } }
private final IRubyObject init(ThreadContext context, IRubyObject rbTypeSize, int count, int align, boolean clear, Block block) { typeSize = calculateTypeSize(context, rbTypeSize); size = typeSize * count; if (size < 0) { throw context.runtime.newArgumentError(String.format("Negative size (%d objects of %d size)", count, typeSize)); } setMemoryIO(Factory.getInstance().allocateDirectMemory(context.runtime, size > 0 ? (int) size : 1, align, clear)); if (getMemoryIO() == null) { Ruby runtime = context.runtime; throw new RaiseException(runtime, runtime.getNoMemoryError(), String.format("Failed to allocate %d objects of %d bytes", typeSize, count), true); } if (block.isGiven()) { try { return block.yield(context, this); } finally { ((AllocatedDirectMemoryIO) getMemoryIO()).free(); setMemoryIO(new FreedMemoryIO(context.runtime)); } } else { return this; } }