general memory handling and AddRef/Release q in MAPI

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Is there a general documentation about how and where to free memory or call
Release on an interface? I assume the following:
- ADRLIST and SRowSet structures (which are essentially the same) must be
allocated and freed line by line (or address-entry by address-entry), but
not property by property (within a line / address). Here the documentation
is contradictory: At some pages it says that - opposed to other functions -
ADRLIST memory must be freed individual, but as the documentation says here:
http://msdn2.microsoft.com/en-us/library/ms529120.aspx
only the grey parts in the drawing may be allocated together. But here:
http://msdn2.microsoft.com/en-us/library/ms528625.aspx
they say that even each SPropValue must be allocated (and therefore freed)
separately. Which variant is now true?
- If a function returns with an error (not a warning) then the returned
memory pointer doesn't need to be freed. Perhaps then no memory pointer is
returned, but this is not always documented and just an assumption. - OR -
any memory pointer returned must be freed if it's not NULL. What is best
practice here? Can I make such assumptions?
- Some functions like IMessage::GetRecipientTable() return COM object
pointers (like IMAPITable in this case). Do I have to call Release after
using that object because the AddRef has been made in the call (not
documented)? Or do I have to call AddRef() myself when I get the pointer
before I use any other function on that object? If I have to call AddRef
myself isn't there a chance that the object "goes away" just between the
return of the called function and my call to AddRef? Is there a complete
list of MAPI functions that act this way? Do all functions act identical
regarding this?
- Any function that returns memory pointers must allocate it with one single
MAPIAllocateBuffer call (and more memory with MAPIAllocateMore) and the
caller must free it with MAPIFreeBuffer.

Please comment on each point above.

Eric


.



Relevant Pages

  • Re: Code density and performance?
    ... Heck, IPF memory requirements make ... It wasn't when the Alpha was designed. ... |> You mean the "POSIX" documentation, ... |>> You may regard breaking standards without even documenting the ...
    (comp.arch)
  • Re: MMIO and gcc re-ordering issue
    ... This is where the lack of documentation causes arch maintainers a big ... readl/writel: strongly ordered wrt one another and other stores ... on x86, memory operations to wc and wc+ memory are not ordered ...
    (Linux-Kernel)
  • Re: [PATCH] Kernels Out Of Memoy(OOM) killer Problem ?
    ... Summary: Patch removes incorrect documentation. ... SysV FS, shm swapping, memory management fixes ... send the line "unsubscribe linux-kernel" in ...
    (Linux-Kernel)
  • Re: Automatic Shared Memory Management
    ... I write an essay about Automatic Shared Memory Management in Oracle 10g ... Oracle is full of undocumented packages, ... about the documentation concept. ... SQL> column DESCRIPTION format a45 wrap ...
    (comp.databases.oracle.server)
  • VirtualLock issue
    ... According to Knowledge Base article 94996, VirtualLock does *not* lock pages into physical ... memory, but locks them into the working set. ... actually changed the implementation to correspond to the documentation; ...
    (microsoft.public.vc.mfc)