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 6655 6a3e741ea70d
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
--- a/include/SDL_rwops.h	Sun Nov 04 21:53:28 2012 -0800
+++ b/include/SDL_rwops.h	Sun Nov 04 23:44:13 2012 -0800
@@ -186,6 +186,7 @@
  *  Read an item of the specified endianness and return in native format.
  */
 /*@{*/
+extern DECLSPEC Uint8 SDLCALL SDL_ReadU8(SDL_RWops * src);
 extern DECLSPEC Uint16 SDLCALL SDL_ReadLE16(SDL_RWops * src);
 extern DECLSPEC Uint16 SDLCALL SDL_ReadBE16(SDL_RWops * src);
 extern DECLSPEC Uint32 SDLCALL SDL_ReadLE32(SDL_RWops * src);
@@ -200,6 +201,7 @@
  *  Write an item of native format to the specified endianness.
  */
 /*@{*/
+extern DECLSPEC size_t SDLCALL SDL_WriteU8(SDL_RWops * dst, Uint8 value);
 extern DECLSPEC size_t SDLCALL SDL_WriteLE16(SDL_RWops * dst, Uint16 value);
 extern DECLSPEC size_t SDLCALL SDL_WriteBE16(SDL_RWops * dst, Uint16 value);
 extern DECLSPEC size_t SDLCALL SDL_WriteLE32(SDL_RWops * dst, Uint32 value);
--- a/src/file/SDL_rwops.c	Sun Nov 04 21:53:28 2012 -0800
+++ b/src/file/SDL_rwops.c	Sun Nov 04 23:44:13 2012 -0800
@@ -640,10 +640,19 @@
 
 /* Functions for dynamically reading and writing endian-specific values */
 
+Uint8
+SDL_ReadU8(SDL_RWops * src)
+{
+    Uint8 value = 0;
+
+    SDL_RWread(src, &value, (sizeof value), 1);
+    return value;
+}
+
 Uint16
 SDL_ReadLE16(SDL_RWops * src)
 {
-    Uint16 value;
+    Uint16 value = 0;
 
     SDL_RWread(src, &value, (sizeof value), 1);
     return (SDL_SwapLE16(value));
@@ -652,7 +661,7 @@
 Uint16
 SDL_ReadBE16(SDL_RWops * src)
 {
-    Uint16 value;
+    Uint16 value = 0;
 
     SDL_RWread(src, &value, (sizeof value), 1);
     return (SDL_SwapBE16(value));
@@ -661,7 +670,7 @@
 Uint32
 SDL_ReadLE32(SDL_RWops * src)
 {
-    Uint32 value;
+    Uint32 value = 0;
 
     SDL_RWread(src, &value, (sizeof value), 1);
     return (SDL_SwapLE32(value));
@@ -670,7 +679,7 @@
 Uint32
 SDL_ReadBE32(SDL_RWops * src)
 {
-    Uint32 value;
+    Uint32 value = 0;
 
     SDL_RWread(src, &value, (sizeof value), 1);
     return (SDL_SwapBE32(value));
@@ -679,7 +688,7 @@
 Uint64
 SDL_ReadLE64(SDL_RWops * src)
 {
-    Uint64 value;
+    Uint64 value = 0;
 
     SDL_RWread(src, &value, (sizeof value), 1);
     return (SDL_SwapLE64(value));
@@ -688,13 +697,19 @@
 Uint64
 SDL_ReadBE64(SDL_RWops * src)
 {
-    Uint64 value;
+    Uint64 value = 0;
 
     SDL_RWread(src, &value, (sizeof value), 1);
     return (SDL_SwapBE64(value));
 }
 
 size_t
+SDL_WriteU8(SDL_RWops * dst, Uint8 value)
+{
+    return (SDL_RWwrite(dst, &value, (sizeof value), 1));
+}
+
+size_t
 SDL_WriteLE16(SDL_RWops * dst, Uint16 value)
 {
     value = SDL_SwapLE16(value);