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

This is a discussion on HeapAlloc with error: The data area passed to a system call is too small. within the Windows Programming forums, part of the Platform Specific Boards category; Hi there, What's the problem with the code below? It results in the error after calling HeapAlloc(hDictMem, HEAP_ZERO_MEMORY, 0x80000L): The ...

  1. #1
    wow
    wow is offline
    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
    wow
    wow is offline
    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, 12:20 PM
  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, 02:29 PM
  3. C Programming Question
    By TK in forum A Brief History of Cprogramming.com
    Replies: 13
    Last Post: 07-04-2002, 08: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, 07:57 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21