Access violation with SDL_RenderText

mike vertex at gmx.at
Sun Oct 29 07:24:07 PST 2006


Thanks! I'll give it a try. And if it doesn't work I'll try passing the  
(zero-terminated) char* pointer I get from my data source through to SDL,  
without buffering the results in an array like I do currently. That might  
be an even better way to do it anyway.

While debugging I somehow find it stranger and stranger -- in addition to  
crashing with toStringz it crashes when using my own function that fetches  
the values (get it, store it in an array, return it to render func), and  
crashes almost predictably in about half the time when fetching data AND  
using toStringz (after memory usage goes up half a meg). No crash when  
using a string constant. Could that be a multi-threading issue? I'm  
rendering the GUI in its own thread, so probably the GC collects stuff in  
the main thread that is currently in use in the render thread?

-Mike

> Perhaps you should buffer the text passed to SDL? Something like the  
> following:
>
> // Do this once in a constructor or globally
> char* renderedTextBuffer = new char[1024];
>
> // Do this to render text
> if (value.length > renderedTextBuffer.length) {
>    renderedTextBuffer = new char[value.length];
> }
> renderedTextBuffer[0 .. value.length] = value;
> renderedTextBuffer[value.length] = 0;
> RenderText(renderedText);
>
> This is effectively what toStringz() does, but it won't allocate memory  
> with every render.
>
>    Bradley



-- 
Erstellt mit Operas revolutionärem E-Mail-Modul: http://www.opera.com/mail/



More information about the Digitalmars-d-learn mailing list