What happens when d3drm_texture_load() is called multiple times on the
same texture? Should that be possible?
> + HeapFree(GetProcessHeap(), 0, texture->image->palette);
> + HeapFree(GetProcessHeap(), 0, texture->image);
This seems a bit suspicious. Supposedly the "image" argument to
d3drm3_CreateTexture() can be used to create a texture on an existing
image. The documentation isn't very explicit about it, but suggests
that the image data isn't copied in that case. So I'm not sure the
texture is supposed to be responsible for destroying the image. In
general I think it's not entirely clear how things like
CreateTexture(), LoadTexture() and InitFromFile() etc. are supposed to
interact.
> + size = GetFileSize(hfile, NULL);
> + if (size == INVALID_FILE_SIZE)
> + {
> + DeleteObject(hfile);
> + return D3DRMERR_BADVALUE;
> + }
You never use "size" after this, but you probably should. I also think
you meant CloseHandle() instead of DeleteObject().
> +D3DRMIMAGE *d3drm_create_image(unsigned char *buffer, BITMAPINFO *info, BOOL palette, BOOL upside_down)
> +{
> + D3DRMPALETTEENTRY *colors = (D3DRMPALETTEENTRY *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 257 * sizeof(*colors));
Is "257" there intentional? The cast is unnecessary. HeapAlloc() can
fail. Do you need HEAP_ZERO_MEMORY here?
This is unsafe. Consider e.g. what happens when the header gives you
0x10000 for width and height.
> + buffer1 = image->buffer1;
> + memset(buffer1, 255, sizeof(unsigned char) * bpl * h);
You just initialised the memory with HEAP_ZERO_MEMORY, and now you're
overwriting it again. At least one of these two initialisations is
unnecessary, and quite possibly both of them.