Thread: HeapAlloc with error: The data area passed to a system call is too small.

  1. #1
    Registered User
    Join Date
    Oct 2005
    Posts
    42

    HeapAlloc with error: The data area passed to a system call is too small.

    Hi there,

    What's the problem with the code below? It results in the error after calling HeapAlloc(hDictMem, HEAP_ZERO_MEMORY, 0x80000L):

    The data area passed to a system call is too small.

    But if 0x80000L is changed to 0x7e000L, then it works.

    Code:
    		// allocate memory for input method dictionaries
    	hDictMem = (HANDLE) HeapCreate(HEAP_NO_SERIALIZE, 0x80016L, 0x80016L);
    	if (NULL == hDictMem)
    	{
    		ErrorHandler();
    		return (FALSE);
    	}
    	pDictMem = (LPSTR) HeapAlloc(hDictMem, HEAP_ZERO_MEMORY, 0x80000L);
    	if (NULL == pDictMem)
    	{
    		ErrorHandler();
    		return (FALSE);
    	}
    Thanks,
    Last edited by wow; 03-18-2006 at 08:06 PM.

  2. #2
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    Quote Originally Posted by MSDN HeapCreate
    However, the heap cannot grow, so the maximum size of a memory block in the heap is a bit less than 0x7FFF8 bytes. Requests to allocate larger blocks will fail, even if the maximum size of the heap is large enough to contain the block.

    If dwMaximumSize is zero, the heap is growable. The heap's size is limited only by available memory. Requests to allocate blocks larger than 0x7FFF8 bytes do not automatically fail; the system calls the VirtualAlloc function to obtain the memory needed for such large blocks. Applications that need to allocate large memory blocks should set dwMaximumSize to zero.
    Typically, when using HeapAlloc, one uses the process heap, obtainable with GetProcessHeap.

  3. #3
    Registered User
    Join Date
    Oct 2005
    Posts
    42
    Thanks very much, it works

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C system call and library call
    By Coconut in forum C Programming
    Replies: 6
    Last Post: 08-22-2002, 11:20 AM
  2. System call to call another C file from Existing C File
    By simly01 in forum C++ Programming
    Replies: 2
    Last Post: 07-31-2002, 01:29 PM
  3. C Programming Question
    By TK in forum A Brief History of Cprogramming.com
    Replies: 13
    Last Post: 07-04-2002, 07:11 PM
  4. Pls help me to do this project in C I need source code
    By sureshmenon74 in forum C Programming
    Replies: 4
    Last Post: 10-04-2001, 06:57 AM