On 19/06/07, Stefan Dösinger stefandoesinger@gmx.at wrote:
- if (hr != S_OK) return NULL;
Any reason for not simply using FAILED(hr) there?
- object->decls = HeapAlloc(GetProcessHeap(), 0, 0);
Is that useful?
Am Dienstag, 19. Juni 2007 12:18 schrieb H. Verbeet:
On 19/06/07, Stefan Dösinger stefandoesinger@gmx.at wrote:
- if (hr != S_OK) return NULL;
Any reason for not simply using FAILED(hr) there?
Actually no, except that it was copypasted from existing code. I'll fix that and resend.
- object->decls = HeapAlloc(GetProcessHeap(), 0, 0);
Is that useful?
Yeah, HeapReAlloc works on object->decls with 0 bytes allocated, but not on a NULL pointer. It keeps the array growing simpler. I can just use HeapReAlloc unconditionally instead of something like this
if(object->decls) HeapRealloc(...); else HeapAlloc(...);
On 19/06/07, Stefan Dösinger stefandoesinger@gmx.at wrote:
Yeah, HeapReAlloc works on object->decls with 0 bytes allocated, but not on a NULL pointer. It keeps the array growing simpler. I can just use HeapReAlloc unconditionally instead of something like this
Well yes, but why not simply start with a >0 size?
Am Dienstag, 19. Juni 2007 14:05 schrieb H. Verbeet:
On 19/06/07, Stefan Dösinger stefandoesinger@gmx.at wrote:
Yeah, HeapReAlloc works on object->decls with 0 bytes allocated, but not on a NULL pointer. It keeps the array growing simpler. I can just use HeapReAlloc unconditionally instead of something like this
Well yes, but why not simply start with a >0 size?
The idea is to avoid allocating unneeded memory as long as we don't know if the app is going to use fvfs at all. D3D8 can be used without setting any fvf, so I don't want to allocate more memory than needed for a feature that isn't necessarily used.
Obviously there is a little memory requirement for the heap management structures that belong to a 0 byte allocation. But extra code to check if This->decls is NULL + a HeapAlloc call need a few bytes too...
I can change that to allocate one or two start entries, but I personally think that 0 bytes are good to start with here.
Stefan Dösinger stefandoesinger@gmx.at writes:
Obviously there is a little memory requirement for the heap management structures that belong to a 0 byte allocation. But extra code to check if This->decls is NULL + a HeapAlloc call need a few bytes too...
I can change that to allocate one or two start entries, but I personally think that 0 bytes are good to start with here.
I don't think so. Either you don't want to waste memory and you don't allocate anything unless needed, or you want to save some work on realloc and you allocate a reasonable buffer to start with. Allocating zero bytes has the drawbacks of both without the benefits.