Announcement

Collapse
No announcement yet.

HeapAlloc

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Michael Mattias
    replied
    Oh, wait a minute, I can see it already.... some ASM-head is going to post...
    Code:
    MACRO CONTINUE  = !NOP

    Leave a comment:


  • Michael Mattias
    replied
    I would bet dollars to donuts that was some 'C' programmer covering a body part against attempting to allocate SIZEOF(something) which was zero and he was too lazy to check the return.

    Correct use is
    Code:
    pData = HeapAlloc (hHEap, flags, size).
    IF ISFALSE pData THEN 
        E = GetLastError  
        yadda yadda 
    ELSE
        CONTINUE       ' <<< a great verb, available in COBOL. 
                            ' for all those places where "something" is required but 
                            ' you really don't need do anything. 
    END IF
    FWIW, these are usable...
    malloc, realloc, free for PB/Win32 September 20, 2002

    Think of these as HeapAlloc with a better user interface.

    MCM

    Leave a comment:


  • Cliff Nichols
    started a topic HeapAlloc

    HeapAlloc

    I am trying to understand the heap, and the allocation deallocation and related, but all examples I seem to find use examples such as
    FUNCTION = HeapAlloc(GetProcessHeap(), %HEAP_ZERO_MEMORY, MAX( 16, nSize + 1))
    Which is the best one I have seen cause to my knowledge "MAX( 16, nSize + 1))" would mean "To choose which is greater? 16? or SIZEOF(datatype)"

    The problem being, I do NOT like hardcoded values with no explanation of what the value means. So I have to ask
    • Why 16? (some minimum value? or what is the real equates?)
    • nSize (obvious from examples is the size) but why the add one? (I can only guess for an added null, or a zero-vs-one based concept or something

    I am sure its in the docs somewhere, but either I am having a CNDS :doh: or just not understanding, so hopefully someone can explain it???
Working...
X