Re: [PATCH 04/13] Add a generic reference counted virObject type

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 07/11/2012 07:35 AM, Daniel P. Berrange wrote:
> From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>
> 
> This introduces a fairly basic reference counted virObject type
> and an associated virClass type, that use atomic operations for
> ref counting.
> 
> +void *virObjectNew(virClassPtr klass)
> +{
> +    virObjectPtr obj = NULL;
> +    char *somebytes;
> +
> +    if (VIR_ALLOC_N(somebytes, klass->objectSize) < 0) {
> +        virReportOOMError();
> +        return NULL;
> +    }
> +    obj = (void*)somebytes;
> +
> +    obj->magic = klass->magic;
> +    obj->klass = klass;
> +    virAtomicIntSet(&obj->refs, 1);

In this instance (and no where else), can't we just do 'obj-refs = 1'
instead of going through virAtomic, since the object hasn't yet been
publicized?  It might make life slightly faster.

-- 
Eric Blake   eblake@xxxxxxxxxx    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]