Skip to content

Instantly share code, notes, and snippets.

View arnsholt's full-sized avatar

Arne Skjærholt arnsholt

View GitHub Profile
@arnsholt
arnsholt / lifecycle.md
Last active December 13, 2015 19:29 — forked from anonymous/lifecycle.md
Outline for better object lifecycles in Zavolaj, and buffers in NQP

Better handling of C objects' lifecycle

To handle certain kinds of operations better (and not leak memory), NativeCall needs to be able to control the lifecycle of objects. Specifically, we need to be able to relinquish control of memory allocated on the Perl side (so that it can be handed to C code), and the ability to take responsibility for a chunk of memory (so that it will be freed when the object is GCed.

To do this, I suggest adding two new functions, adopt() and disown(), and reworking the string marshalling rules.

adopt() and disown()

These two functions do what you'd expect. adopt() assumes control of the memory allocated by the object, indicating that it should be freed when the object is GCed. disown() releases control, so that the memory is untouched on GC. Neither function should apply recursively to the members of structs or arrays.

NativeCall objects created in Perl 6 will be adopted by default, and those returned from C will be disowned by default.

From 688c9cd76289ce72ce37ace500f33a2b001a2c9c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Arne=20Skj=C3=A6rholt?= <arnsholt@gmail.com>
Date: Wed, 30 Jun 2010 17:41:08 +0200
Subject: [PATCH] Only print unique directories, and not their prefixes. v2.
---
ufo | 20 ++++++++++++++++++--
1 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/ufo b/ufo