Added SDL_ReadU8() and SDL_WriteU8() for consistency with the rest of the API.
authorSam Lantinga <slouken@libsdl.org>
Sun, 04 Nov 2012 23:44:13 -0800
changeset 66556a3e741ea70d
parent 6654 2ecfb25be1e2
child 6656 8eb6e2e2ab97
Added SDL_ReadU8() and SDL_WriteU8() for consistency with the rest of the API.
include/SDL_rwops.h
src/file/SDL_rwops.c
     1.1 --- a/include/SDL_rwops.h	Sun Nov 04 21:53:28 2012 -0800
     1.2 +++ b/include/SDL_rwops.h	Sun Nov 04 23:44:13 2012 -0800
     1.3 @@ -186,6 +186,7 @@
     1.4   *  Read an item of the specified endianness and return in native format.
     1.5   */
     1.6  /*@{*/
     1.7 +extern DECLSPEC Uint8 SDLCALL SDL_ReadU8(SDL_RWops * src);
     1.8  extern DECLSPEC Uint16 SDLCALL SDL_ReadLE16(SDL_RWops * src);
     1.9  extern DECLSPEC Uint16 SDLCALL SDL_ReadBE16(SDL_RWops * src);
    1.10  extern DECLSPEC Uint32 SDLCALL SDL_ReadLE32(SDL_RWops * src);
    1.11 @@ -200,6 +201,7 @@
    1.12   *  Write an item of native format to the specified endianness.
    1.13   */
    1.14  /*@{*/
    1.15 +extern DECLSPEC size_t SDLCALL SDL_WriteU8(SDL_RWops * dst, Uint8 value);
    1.16  extern DECLSPEC size_t SDLCALL SDL_WriteLE16(SDL_RWops * dst, Uint16 value);
    1.17  extern DECLSPEC size_t SDLCALL SDL_WriteBE16(SDL_RWops * dst, Uint16 value);
    1.18  extern DECLSPEC size_t SDLCALL SDL_WriteLE32(SDL_RWops * dst, Uint32 value);
     2.1 --- a/src/file/SDL_rwops.c	Sun Nov 04 21:53:28 2012 -0800
     2.2 +++ b/src/file/SDL_rwops.c	Sun Nov 04 23:44:13 2012 -0800
     2.3 @@ -640,10 +640,19 @@
     2.4  
     2.5  /* Functions for dynamically reading and writing endian-specific values */
     2.6  
     2.7 +Uint8
     2.8 +SDL_ReadU8(SDL_RWops * src)
     2.9 +{
    2.10 +    Uint8 value = 0;
    2.11 +
    2.12 +    SDL_RWread(src, &value, (sizeof value), 1);
    2.13 +    return value;
    2.14 +}
    2.15 +
    2.16  Uint16
    2.17  SDL_ReadLE16(SDL_RWops * src)
    2.18  {
    2.19 -    Uint16 value;
    2.20 +    Uint16 value = 0;
    2.21  
    2.22      SDL_RWread(src, &value, (sizeof value), 1);
    2.23      return (SDL_SwapLE16(value));
    2.24 @@ -652,7 +661,7 @@
    2.25  Uint16
    2.26  SDL_ReadBE16(SDL_RWops * src)
    2.27  {
    2.28 -    Uint16 value;
    2.29 +    Uint16 value = 0;
    2.30  
    2.31      SDL_RWread(src, &value, (sizeof value), 1);
    2.32      return (SDL_SwapBE16(value));
    2.33 @@ -661,7 +670,7 @@
    2.34  Uint32
    2.35  SDL_ReadLE32(SDL_RWops * src)
    2.36  {
    2.37 -    Uint32 value;
    2.38 +    Uint32 value = 0;
    2.39  
    2.40      SDL_RWread(src, &value, (sizeof value), 1);
    2.41      return (SDL_SwapLE32(value));
    2.42 @@ -670,7 +679,7 @@
    2.43  Uint32
    2.44  SDL_ReadBE32(SDL_RWops * src)
    2.45  {
    2.46 -    Uint32 value;
    2.47 +    Uint32 value = 0;
    2.48  
    2.49      SDL_RWread(src, &value, (sizeof value), 1);
    2.50      return (SDL_SwapBE32(value));
    2.51 @@ -679,7 +688,7 @@
    2.52  Uint64
    2.53  SDL_ReadLE64(SDL_RWops * src)
    2.54  {
    2.55 -    Uint64 value;
    2.56 +    Uint64 value = 0;
    2.57  
    2.58      SDL_RWread(src, &value, (sizeof value), 1);
    2.59      return (SDL_SwapLE64(value));
    2.60 @@ -688,13 +697,19 @@
    2.61  Uint64
    2.62  SDL_ReadBE64(SDL_RWops * src)
    2.63  {
    2.64 -    Uint64 value;
    2.65 +    Uint64 value = 0;
    2.66  
    2.67      SDL_RWread(src, &value, (sizeof value), 1);
    2.68      return (SDL_SwapBE64(value));
    2.69  }
    2.70  
    2.71  size_t
    2.72 +SDL_WriteU8(SDL_RWops * dst, Uint8 value)
    2.73 +{
    2.74 +    return (SDL_RWwrite(dst, &value, (sizeof value), 1));
    2.75 +}
    2.76 +
    2.77 +size_t
    2.78  SDL_WriteLE16(SDL_RWops * dst, Uint16 value)
    2.79  {
    2.80      value = SDL_SwapLE16(value);