[SDL] Scrap for OSX (copy and paste)

Josiah ravean_uo at hotmail.com
Tue Dec 4 16:09:32 PST 2007


E. Wing <ewmailing <at> gmail.com> writes:

> 
> Attached is my modified version. To compile on OS X, your build system
> should skip the scrap.c and build scrap_OSX.m instead.
> 
> -Eric

Thanks Eric, I managed to get it compiling correctly but whenever I try and copy
and past I get an error:

main(467,0xa000ed88) malloc: *** error for object 0xbfffddd0: pointer being
reallocated was not
allocated
main(467,0xa000ed88) malloc: *** set a breakpoint in szone_error to debug
Text scrap is empty

The code I am using to paste is taken from the original scrap.c and works in
Windows:

void getclipboard(char *scrap)
{
	int scraplen;
	char *cp;
	int   i;

	SDLScrap_PasteFromClipboard(SDLSCRAP_TEXT, &scraplen, &scrap);
        if ( scraplen == 0 ) {
		printf("Text scrap is empty\n");
	} else {
		{ /* Convert the scrap from Mac text to UNIX text */

			for ( cp=scrap, i=0; i<scraplen; ++cp, ++i ) {
				if ( *cp == '\r' )
					*cp = '\n';
			}
		}
		printf("Scrap is: %s\n", scrap);
	}
}

Any ideas?

Thanks!



More information about the SDL mailing list