The structure used to manage the shared resource must start with an apr_bucket_refcount which is updated by the general-purpose refcount code. A pointer to the bucket-type-dependent private data structure can be cast to a pointer to an apr_bucket_refcount and vice versa.