src/file/SDL_rwops.c
changeset 6999 681820ca0e78
parent 6996 bc0fd5bced25
child 7011 82bbfbbc720e
     1.1 --- a/src/file/SDL_rwops.c	Tue Mar 12 18:28:40 2013 -0700
     1.2 +++ b/src/file/SDL_rwops.c	Wed Mar 13 08:35:03 2013 -0700
     1.3 @@ -513,6 +513,7 @@
     1.4      rwops->read = Android_JNI_FileRead;
     1.5      rwops->write = Android_JNI_FileWrite;
     1.6      rwops->close = Android_JNI_FileClose;
     1.7 +    rwops->type = SDL_RWOPS_JNIFILE;
     1.8  
     1.9  #elif defined(__WIN32__)
    1.10      rwops = SDL_AllocRW();
    1.11 @@ -527,6 +528,7 @@
    1.12      rwops->read = windows_file_read;
    1.13      rwops->write = windows_file_write;
    1.14      rwops->close = windows_file_close;
    1.15 +    rwops->type = SDL_RWOPS_WINFILE;
    1.16  
    1.17  #elif HAVE_STDIO_H
    1.18      {
    1.19 @@ -570,6 +572,7 @@
    1.20          rwops->close = stdio_close;
    1.21          rwops->hidden.stdio.fp = fp;
    1.22          rwops->hidden.stdio.autoclose = autoclose;
    1.23 +        rwops->type = SDL_RWOPS_STDFILE;
    1.24      }
    1.25      return (rwops);
    1.26  }
    1.27 @@ -585,7 +588,15 @@
    1.28  SDL_RWops *
    1.29  SDL_RWFromMem(void *mem, int size)
    1.30  {
    1.31 -    SDL_RWops *rwops;
    1.32 +    SDL_RWops *rwops = NULL;
    1.33 +    if (!mem) {
    1.34 +      SDL_InvalidParamError("mem");
    1.35 +      return (rwops);
    1.36 +    }
    1.37 +    if (!size) {
    1.38 +      SDL_InvalidParamError("size");
    1.39 +      return (rwops);
    1.40 +    }
    1.41  
    1.42      rwops = SDL_AllocRW();
    1.43      if (rwops != NULL) {
    1.44 @@ -597,6 +608,7 @@
    1.45          rwops->hidden.mem.base = (Uint8 *) mem;
    1.46          rwops->hidden.mem.here = rwops->hidden.mem.base;
    1.47          rwops->hidden.mem.stop = rwops->hidden.mem.base + size;
    1.48 +        rwops->type = SDL_RWOPS_MEMORY;
    1.49      }
    1.50      return (rwops);
    1.51  }
    1.52 @@ -604,7 +616,15 @@
    1.53  SDL_RWops *
    1.54  SDL_RWFromConstMem(const void *mem, int size)
    1.55  {
    1.56 -    SDL_RWops *rwops;
    1.57 +    SDL_RWops *rwops = NULL;
    1.58 +    if (!mem) {
    1.59 +      SDL_InvalidParamError("mem");
    1.60 +      return (rwops);
    1.61 +    }
    1.62 +    if (!size) {
    1.63 +      SDL_InvalidParamError("size");
    1.64 +      return (rwops);
    1.65 +    }
    1.66  
    1.67      rwops = SDL_AllocRW();
    1.68      if (rwops != NULL) {
    1.69 @@ -616,6 +636,7 @@
    1.70          rwops->hidden.mem.base = (Uint8 *) mem;
    1.71          rwops->hidden.mem.here = rwops->hidden.mem.base;
    1.72          rwops->hidden.mem.stop = rwops->hidden.mem.base + size;
    1.73 +        rwops->type = SDL_RWOPS_MEMORY_RO;
    1.74      }
    1.75      return (rwops);
    1.76  }
    1.77 @@ -629,6 +650,7 @@
    1.78      if (area == NULL) {
    1.79          SDL_OutOfMemory();
    1.80      }
    1.81 +    area->type = SDL_RWOPS_UNKNOWN;
    1.82      return (area);
    1.83  }
    1.84