lib: Add memarea API This can be used to create reference counted memory areas where a callback is called once the refcount drops to zero.