Re: LW for Windows - very good news!
Matt Lewis wrote:
> Rob,
>
> dos_rescue.ew is interesting, however, I think you have a memory leak in
> the call to DrawText, where you call allocate_string() instead of using
> the already allocated pointer stored in 's':
> }}}
<eucode>
> global procedure putsxy(sequence pos, sequence string,
> integer fcolor, integer bcolor)
> atom s
>
> poke4(charRect, pos[1])
> poke4(charRect+CHAR_TOP, pos[2])
> poke4(charRect+CHAR_RIGHT, pos[1]+length(string)*8)
> poke4(charRect+CHAR_BOTTOM, pos[2]+18)
> s = allocate_string(string) -- could reserve large space instead
> c_proc(SetTextColor, {hdc, color_map[1+fcolor]})
>
> c_proc(SetBkColor, {hdc, color_map[1+bcolor]})
>
> c_proc(SetBkMode, {hdc, OPAQUE})
>
> c_proc(DrawText, {hdc, allocate_string(string), -1, charRect,
> DT_SINGLE_LINE})
> free(s)
> end procedure
> </eucode>
{{{
Thanks for spotting that.
I must have intended to use s, but forgot.
Here's my new code:
global procedure putsxy(sequence pos, sequence string,
integer fcolor, integer bcolor)
atom s
poke4(charRect, pos[1])
poke4(charRect+CHAR_TOP, pos[2])
poke4(charRect+CHAR_RIGHT, pos[1]+length(string)*8)
poke4(charRect+CHAR_BOTTOM, pos[2]+18)
c_proc(SetTextColor, {hdc, color_map[1+fcolor]})
c_proc(SetBkColor, {hdc, color_map[1+bcolor]})
c_proc(SetBkMode, {hdc, OPAQUE})
s = allocate_string(string)
c_proc(DrawText, {hdc, s, -1, charRect, DT_SINGLE_LINE})
free(s)
end procedure
I recompiled and uploaded the new version.
I don't think allocating a fixed, large space for the string
will have any significant effect on speed. On my machine,
lw, even when interpreted, only uses about 1% of the available CPU.
It was using almost 100%, until I inserted a 1 ms sleep
inside the only time-share task, task_video_save(), when the program
finds that it has no video data to write out, and no real-time
tasks ready to run at the moment.
Thanks,
Rob Craig
Rapid Deployment Software
http://www.RapidEuphoria.com
|
Not Categorized, Please Help
|
|