comparison src/video/SDL_RLEaccel.c @ 1336:3692456e7b0f

Use SDL_ prefixed versions of C library functions. FIXME: Change #include <stdlib.h> to #include "SDL_stdlib.h" Change #include <string.h> to #include "SDL_string.h" Make sure nothing else broke because of this...
author Sam Lantinga <slouken@libsdl.org>
date Tue, 07 Feb 2006 06:59:48 +0000
parents 450721ad5436
children 604d73db6802
comparison
equal deleted inserted replaced
1335:c39265384763 1336:3692456e7b0f
1465 default: 1465 default:
1466 return -1; /* anything else unsupported right now */ 1466 return -1; /* anything else unsupported right now */
1467 } 1467 }
1468 1468
1469 maxsize += sizeof(RLEDestFormat); 1469 maxsize += sizeof(RLEDestFormat);
1470 rlebuf = (Uint8 *)malloc(maxsize); 1470 rlebuf = (Uint8 *)SDL_malloc(maxsize);
1471 if(!rlebuf) { 1471 if(!rlebuf) {
1472 SDL_OutOfMemory(); 1472 SDL_OutOfMemory();
1473 return -1; 1473 return -1;
1474 } 1474 }
1475 { 1475 {
1595 #undef ADD_TRANSL_COUNTS 1595 #undef ADD_TRANSL_COUNTS
1596 1596
1597 /* Now that we have it encoded, release the original pixels */ 1597 /* Now that we have it encoded, release the original pixels */
1598 if((surface->flags & SDL_PREALLOC) != SDL_PREALLOC 1598 if((surface->flags & SDL_PREALLOC) != SDL_PREALLOC
1599 && (surface->flags & SDL_HWSURFACE) != SDL_HWSURFACE) { 1599 && (surface->flags & SDL_HWSURFACE) != SDL_HWSURFACE) {
1600 free( surface->pixels ); 1600 SDL_free( surface->pixels );
1601 surface->pixels = NULL; 1601 surface->pixels = NULL;
1602 } 1602 }
1603 1603
1604 /* realloc the buffer to release unused memory */ 1604 /* realloc the buffer to release unused memory */
1605 { 1605 {
1606 Uint8 *p = realloc(rlebuf, dst - rlebuf); 1606 Uint8 *p = SDL_realloc(rlebuf, dst - rlebuf);
1607 if(!p) 1607 if(!p)
1608 p = rlebuf; 1608 p = rlebuf;
1609 surface->map->sw_data->aux_data = p; 1609 surface->map->sw_data->aux_data = p;
1610 } 1610 }
1611 1611
1673 maxsize = surface->h * (4 * (surface->w / 65535 + 1) 1673 maxsize = surface->h * (4 * (surface->w / 65535 + 1)
1674 + surface->w * 4) + 4; 1674 + surface->w * 4) + 4;
1675 break; 1675 break;
1676 } 1676 }
1677 1677
1678 rlebuf = (Uint8 *)malloc(maxsize); 1678 rlebuf = (Uint8 *)SDL_malloc(maxsize);
1679 if ( rlebuf == NULL ) { 1679 if ( rlebuf == NULL ) {
1680 SDL_OutOfMemory(); 1680 SDL_OutOfMemory();
1681 return(-1); 1681 return(-1);
1682 } 1682 }
1683 1683
1729 ADD_COUNTS(maxn, 0); 1729 ADD_COUNTS(maxn, 0);
1730 skip -= maxn; 1730 skip -= maxn;
1731 } 1731 }
1732 len = MIN(run, maxn); 1732 len = MIN(run, maxn);
1733 ADD_COUNTS(skip, len); 1733 ADD_COUNTS(skip, len);
1734 memcpy(dst, srcbuf + runstart * bpp, len * bpp); 1734 SDL_memcpy(dst, srcbuf + runstart * bpp, len * bpp);
1735 dst += len * bpp; 1735 dst += len * bpp;
1736 run -= len; 1736 run -= len;
1737 runstart += len; 1737 runstart += len;
1738 while(run) { 1738 while(run) {
1739 len = MIN(run, maxn); 1739 len = MIN(run, maxn);
1740 ADD_COUNTS(0, len); 1740 ADD_COUNTS(0, len);
1741 memcpy(dst, srcbuf + runstart * bpp, len * bpp); 1741 SDL_memcpy(dst, srcbuf + runstart * bpp, len * bpp);
1742 dst += len * bpp; 1742 dst += len * bpp;
1743 runstart += len; 1743 runstart += len;
1744 run -= len; 1744 run -= len;
1745 } 1745 }
1746 if(!blankline) 1746 if(!blankline)
1755 #undef ADD_COUNTS 1755 #undef ADD_COUNTS
1756 1756
1757 /* Now that we have it encoded, release the original pixels */ 1757 /* Now that we have it encoded, release the original pixels */
1758 if((surface->flags & SDL_PREALLOC) != SDL_PREALLOC 1758 if((surface->flags & SDL_PREALLOC) != SDL_PREALLOC
1759 && (surface->flags & SDL_HWSURFACE) != SDL_HWSURFACE) { 1759 && (surface->flags & SDL_HWSURFACE) != SDL_HWSURFACE) {
1760 free( surface->pixels ); 1760 SDL_free( surface->pixels );
1761 surface->pixels = NULL; 1761 surface->pixels = NULL;
1762 } 1762 }
1763 1763
1764 /* realloc the buffer to release unused memory */ 1764 /* realloc the buffer to release unused memory */
1765 { 1765 {
1766 /* If realloc returns NULL, the original block is left intact */ 1766 /* If realloc returns NULL, the original block is left intact */
1767 Uint8 *p = realloc(rlebuf, dst - rlebuf); 1767 Uint8 *p = SDL_realloc(rlebuf, dst - rlebuf);
1768 if(!p) 1768 if(!p)
1769 p = rlebuf; 1769 p = rlebuf;
1770 surface->map->sw_data->aux_data = p; 1770 surface->map->sw_data->aux_data = p;
1771 } 1771 }
1772 1772
1843 uncopy_transl = uncopy_transl_16; 1843 uncopy_transl = uncopy_transl_16;
1844 } else { 1844 } else {
1845 uncopy_opaque = uncopy_transl = uncopy_32; 1845 uncopy_opaque = uncopy_transl = uncopy_32;
1846 } 1846 }
1847 1847
1848 surface->pixels = malloc(surface->h * surface->pitch); 1848 surface->pixels = SDL_malloc(surface->h * surface->pitch);
1849 if ( !surface->pixels ) { 1849 if ( !surface->pixels ) {
1850 return(SDL_FALSE); 1850 return(SDL_FALSE);
1851 } 1851 }
1852 /* fill background with transparent pixels */ 1852 /* fill background with transparent pixels */
1853 memset(surface->pixels, 0, surface->h * surface->pitch); 1853 SDL_memset(surface->pixels, 0, surface->h * surface->pitch);
1854 1854
1855 dst = surface->pixels; 1855 dst = surface->pixels;
1856 srcbuf = (Uint8 *)(df + 1); 1856 srcbuf = (Uint8 *)(df + 1);
1857 for(;;) { 1857 for(;;) {
1858 /* copy opaque pixels */ 1858 /* copy opaque pixels */
1907 if((surface->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) { 1907 if((surface->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) {
1908 SDL_Rect full; 1908 SDL_Rect full;
1909 unsigned alpha_flag; 1909 unsigned alpha_flag;
1910 1910
1911 /* re-create the original surface */ 1911 /* re-create the original surface */
1912 surface->pixels = malloc(surface->h * surface->pitch); 1912 surface->pixels = SDL_malloc(surface->h * surface->pitch);
1913 if ( !surface->pixels ) { 1913 if ( !surface->pixels ) {
1914 /* Oh crap... */ 1914 /* Oh crap... */
1915 surface->flags |= SDL_RLEACCEL; 1915 surface->flags |= SDL_RLEACCEL;
1916 return; 1916 return;
1917 } 1917 }
1935 } 1935 }
1936 } 1936 }
1937 } 1937 }
1938 1938
1939 if ( surface->map && surface->map->sw_data->aux_data ) { 1939 if ( surface->map && surface->map->sw_data->aux_data ) {
1940 free(surface->map->sw_data->aux_data); 1940 SDL_free(surface->map->sw_data->aux_data);
1941 surface->map->sw_data->aux_data = NULL; 1941 surface->map->sw_data->aux_data = NULL;
1942 } 1942 }
1943 } 1943 }
1944 } 1944 }
1945 1945