Microsoft KB Archive/105533

From BetaArchive Wiki

BUG: Problems with Local/Global Memory Management APIs PSS ID Number: Q105533 Article last modified on 07-27-1994

3.10

WINDOWS NT

The information in this article applies to:
- Microsoft Win32 Software Development Kit (SDK) for Windows NT version 3.1

SYMPTOMS

The following is a list of problems that may be encountered when the Local and Global memory management application programming interfaces (APIs) are used:

  1. The documentation for LocalUnlock() says that if the specified memory is fixed, the API returns nonzero.

    The API returns 0 (zero) even if the memory is fixed.

  2. The documentation for LocalReAlloc() states that if the cbBytes parameter is 0, the memory is movable and discardable, and the lock count is zero, then the API returns a handle to a discarded memory object. If the lock count is nonzero, the API will fail.

    The API succeeds even if the lock count is nonzero.

  3. The documentation for LocalFree() and for GlobalFree() indicates that if the parameter is NULL, the function will fail and the system generate an access violation.

    The APIs do not generate an access violation.

  4. The documentation for LocalFree() and for GlobalFree() states that the API will fail if passed a handle to a memory object that is locked.

    The APIs free the memory even if the lock count is nonzero.

RESOLUTION/STATUS

The following are confirmations of the corresponding problems described in the previous section:

  1. This is an error in the documentation. Memory that is already unlocked will cause LocalUnlock() to return FALSE and GetLastError() will report ERROR_NOT_LOCKED. Memory allocated with LMEM_FIXED always has a lock count of zero, and therefore GetLastError() will also return ERROR_NOT_LOCKED in this case.
  2. This is a bug in Local/GlobalReAlloc().
  3. This is an error in the documentation. The Help should state that Local/GlobalFree() will return NULL if an attempt is made to free NULL. This is compatible with Windows 3.1.
  4. This is a bug in Local/GlobalFree().

Additional reference words: 3.10 KBCategory: Prg KBSubcategory: BseMm

=================================================================

Copyright Microsoft Corporation 1994.