mozilla
검색 결과

    NPN_MemAlloc

    아직 자원 봉사자들이 한국어로 현재 문서를 번역하지 않았습니다. 가입해서 이 문서가 번역되는 일에 함께 해 주세요!

    Summary

    Allocates memory from the browser's memory space.

    Syntax

    #include <npapi.h>
     
    void *NPN_MemAlloc (uint32 size);
    

    Parameters

    The function has the following parameters:

    size
    Size of memory, in bytes, to allocate in the browser's memory space.

    Returns

    • If successful, the function returns a pointer to the allocated memory, in bytes.
    • If insufficient memory is available, the plug-in returns null.

    Description

    The plug-in calls NPN_MemAlloc to allocate a specified amount of memory in the browser's memory space. If you allocate saved instance data with NPP_Destroy, be sure to use NPN_MemAlloc to allocate memory. This ensures that the browser can free the saved data at a later time with the equivalent of NPN_MemFree.

    Since the browser and plug-ins share the same memory space, NPN_MemAlloc allows plug-ins to take advantage of any customized memory allocation scheme the application may have, and allows the application to manage its memory more flexibly and efficiently.

    Mac OS

    NPN_MemAlloc is particularly important on Mac OS, since the Mac OS version of the browser frequently fills its memory partition with cached data that is only purged as necessary. Since NPN_MemAlloc automatically frees cached information if necessary to fulfill the request, calls to NPN_MemAlloc may succeed where direct calls to NewPtr fail.

    Existing calls to NPN_MemFlush have no effect. You only need to use NPN_MemFlush in situations where you cannot use NPN_MemAlloc, for example, when calling system methods that allocate memory indirectly.

    See also

    문서 태그 및 공헌자

    Contributors to this page: Pmash, jswisher, ethertank
    최종 변경: ethertank,