Commit f5bac9ff authored by Kevin Wolf's avatar Kevin Wolf

vesa: Speicherleck gefixt

! vesa: vesamodeinfo kann auch auf dem Stack alloziert werden, dann
  sparen wir uns nicht nur das malloc(), sondern leaken das Ding auch
  nicht mehr.
Signed-off-by: Kevin Wolf's avatarKevin Wolf <kevin@tyndur.org>
parent d2e29cc5
......@@ -105,7 +105,7 @@ int cdi_video_vesa_initialize
* Infoblock
* @return Zeiger auf Modus-Informationsblock. 0 bei Fehler.
*/
struct cdi_video_vesa_mode_info* cdi_video_vesa_get_mode(int modenum);
void cdi_video_vesa_get_mode(int modenum, struct cdi_video_vesa_mode_info* mi);
/**
* Setzt den Modus via int10
......
......@@ -80,38 +80,25 @@ int cdi_video_vesa_initialize
printf("Mode: %04X\n", modeptr[i]);
#endif
struct cdi_video_vesa_mode_info *modeinfo;
modeinfo = cdi_video_vesa_get_mode(modeptr[i]);
struct cdi_video_vesa_mode_info modeinfo;
cdi_video_vesa_get_mode(modeptr[i], &modeinfo);
// Call Callback
if (mode_callback != NULL && modeinfo != NULL) {
(*mode_callback)(modeptr[i], modeinfo);
free(modeinfo);
if (mode_callback != NULL) {
(*mode_callback)(modeptr[i], &modeinfo);
}
}
return 0;
}
struct cdi_video_vesa_mode_info* cdi_video_vesa_get_mode(int modenum)
void cdi_video_vesa_get_mode(int modenum, struct cdi_video_vesa_mode_info* mi)
{
struct cdi_bios_memory infomemory;
cdi_list_t memorylist;
memorylist = cdi_list_create();
struct cdi_video_vesa_mode_info* modeinfo;
struct cdi_mem_area* modeinfo_area;
modeinfo_area = cdi_mem_alloc(sizeof(struct cdi_video_vesa_mode_info),
CDI_MEM_PHYS_CONTIGUOUS | CDI_MEM_DMA_4G | 12);
if (modeinfo_area == NULL) {
fprintf(stderr, "cdi_mem_alloc failed.\n");
return NULL;
}
modeinfo = modeinfo_area->vaddr;
infomemory.src = modeinfo;
infomemory.src = mi;
infomemory.dest = 0x80000;
infomemory.size = sizeof(struct cdi_video_vesa_mode_info);
......@@ -139,8 +126,6 @@ struct cdi_video_vesa_mode_info* cdi_video_vesa_get_mode(int modenum)
printf("LinearFB: 0x%x\nOffscreenMem: 0x%x\nOffscreenSize: %d\n", modeinfo->linearfb,
modeinfo->offscreenmem, modeinfo->offscreensize);
#endif
return modeinfo;
}
int cdi_video_vesa_change_mode(int modenumber)
......
......@@ -159,18 +159,18 @@ int vesa_display_set_mode(struct cdi_video_device* device,
bitmap = calloc(1, sizeof(struct cdi_video_bitmap));
}
struct cdi_video_vesa_mode_info* vesamodeinfo;
vesamodeinfo = cdi_video_vesa_get_mode(vesamode->vesamode);
struct cdi_video_vesa_mode_info vesamodeinfo;
cdi_video_vesa_get_mode(vesamode->vesamode, &vesamodeinfo);
bitmap->width = mode->width;
bitmap->height = mode->height;
bitmap->format.bpp = vesamodeinfo->depth;
bitmap->format.red_bits = vesamodeinfo->redmasksize;
bitmap->format.red_offset = vesamodeinfo->redfieldpos;
bitmap->format.green_bits = vesamodeinfo->greenmasksize;
bitmap->format.green_offset = vesamodeinfo->greenfieldpos;
bitmap->format.blue_bits = vesamodeinfo->bluemasksize;
bitmap->format.blue_offset = vesamodeinfo->bluefieldpos;
bitmap->format.bpp = vesamodeinfo.depth;
bitmap->format.red_bits = vesamodeinfo.redmasksize;
bitmap->format.red_offset = vesamodeinfo.redfieldpos;
bitmap->format.green_bits = vesamodeinfo.greenmasksize;
bitmap->format.green_offset = vesamodeinfo.greenfieldpos;
bitmap->format.blue_bits = vesamodeinfo.bluemasksize;
bitmap->format.blue_offset = vesamodeinfo.bluefieldpos;
bitmap->format.alpha_bits = 0;
bitmap->format.alpha_offset = 0;
......@@ -189,12 +189,12 @@ int vesa_display_set_mode(struct cdi_video_device* device,
bitmap->device = device;
bitmap->pitch = vesamodeinfo->pitch;
bitmap->pitch = vesamodeinfo.pitch;
// bitmap->in_vram = 1;
// bitmap->pixeldata = NULL; // Im VRAM, passt so
stdout = 0;
printf("linearfb: 0x%08x\n", vesamodeinfo->linearfb);
printf("linearfb: 0x%08x\n", vesamodeinfo.linearfb);
// Alten Speicher ggf. vorher freigeben
if (device->vram) {
......@@ -207,7 +207,9 @@ int vesa_display_set_mode(struct cdi_video_device* device,
// FIXME Nach display oder device verschieben.
// struct cdi_mem_area* mem;
device->vram = cdi_mem_map(vesamodeinfo->linearfb, bitmap->height * bitmap->pitch);
device->vram = cdi_mem_map(vesamodeinfo.linearfb,
bitmap->height * bitmap->pitch);
// bitmap->in_vram = 0;
// bitmap->pixeldata = mem->vaddr;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment