Hello, Nelson.
Thank you for your response.
On Tue, 17 Dec 2009, Nelson B Bolyard wrote:
On 2009-12-16 03:01 PST, Konstantin Andreev wrote:
I see NSS code uses SECITEM_AllocItem() and PORT_Arena{,Z}Alloc() memory
allocation routines almost interchangeably.
Yes, almost.
I see that SECITEM_AllocItem(), basically, just wraps PORT_ArenaZAlloc() into the
"arena mark" brackets:
I would not say that is the major difference. The major difference is that
SECITEM_AllocItem will optionally allocate the Item, as well as the buffer to
which the item points.
This feature is certainly clear, so I did not mention it.
The use of arena pool marks is merely necessary to ensure proper cleanup in the
rare case where the first of those two allocations succeeds but the second
fails.
Hmm... interesting. Do I understand right, "arena marks" are like transaction
boundaries for memory allocations ? May I consider the equivalence:
PORT_ArenaMark ~~ begin transaction
PORT_ArenaUnmark ~~ commit transaction
PORT_ArenaRelease ~~ rollback transaction
If you don't use the optional feature to allocate the Item itself, then calling
SECITEM_AllocItem to allocate only the buffer is completely equivalent to
calling PORT_ArenaAlloc directly.
Ok, it is pretty clear now, thanks.
Could you, please, advice, which allocation routine (SECITEM_AllocItem or
PORT_Arena{,Z}Alloc) should I use for my particular code ?
OK. :)
--
dev-tech-crypto mailing list
dev-tech-crypto@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-tech-crypto