Re: A89: Re: Re: Custom Variables


[Prev][Next][Index][Thread]

Re: A89: Re: Re: Custom Variables




On Mon, Jul 17, 2000 at 18:16:58 +0200, Zeljko Juric wrote:
> 
>   if(!(h=HeapAlloc(HeapMax()))) return H_NULL;
>   if(!(sym_entry=DerefSym(SymAdd(sptr)))) return H_NULL;

Assume the user has 1000 bytes available. Then HeapAlloc(HeapMax()) works
and allocates everything. Now SymAdd() fails because there's no room to add
the new entry in the folder and your function returns. Where did those 1000
bytes go???


>   *(long*)HLock(sym_entry->handle=h)=0x00010000;

Why lock?

Also, keep in mind that size==HeapSize(HeapAlloc(size)) is not always true!
(Not that you seem to rely on it, I'm just pointing out the fact...)

Actually it's HeapSize(HeapAlloc(size))==(size<6 ? 6 : (size+1)&-2)


/Johan



References: