[systemd-devel] [PATCH] prioq: avoid to swap item index

Yang Chengwei chengwei.yang at intel.com
Mon Dec 16 18:05:11 PST 2013


> 
> Sorry, still not getting what you want to say.
> 
> Mayb ethere is some confusion regarding what .idx actually is? .idx is

Yes, it proved that I was wrong, that patch is right only and only when
both items' idx is NULL, this apparently not the case.

Please ignore that patch, thanks for your time.

--
Thanks,
Chengwei

> supposed to point to some index integer that is stored in the actual
> structure the user added to the priority queue and that can be used to
> quickly remove an entry from the priority queue without requiring it to
> be the first one. 
> 
> In the swap() call we hence first swap the the data and idx pointers
> themselves, and then in a second step we finally update what the idx
> pointers actually point to to the new index of the item in our priority
> queue.
> 
> I totally don't see how any of that was redundant. We must make sure
> after all that after the swap:
> 
> a) For both entries we know that the data pointer has been swapped
> b) For both entries we know that the pointer to the index value that is part of the user structure has been swapped
> c) For both entries we know that the index value that is part of the user structure has been swapped
> 
> Lennart
> 
> -- 
> Lennart Poettering, Red Hat
> _______________________________________________
> systemd-devel mailing list
> systemd-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: Digital signature
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20131217/901e2a8b/attachment.pgp>


More information about the systemd-devel mailing list