Fix pow <small> and a very stypid bug with dummy srcs(0 equals to tmp0.x)</small...
[mesa.git] / src / mesa / main / bufferobj.c
index 9d2fc95be31dc24b5459d07c14834103d168ab6f..03aec367c438942073a4a8b62ea595061c507f0d 100644 (file)
@@ -310,7 +310,7 @@ _mesa_buffer_get_subdata( GLcontext *ctx, GLenum target, GLintptrARB offset,
 {
    (void) ctx; (void) target;
 
-   if (bufObj->Data && ((GLuint) (size + offset) <= bufObj->Size)) {
+   if (bufObj->Data && ((GLsizeiptrARB) (size + offset) <= bufObj->Size)) {
       _mesa_memcpy( data, (GLubyte *) bufObj->Data + offset, size );
    }
 }
@@ -433,6 +433,7 @@ _mesa_validate_pbo_access(GLuint dimensions,
                           GLenum format, GLenum type, const GLvoid *ptr)
 {
    GLvoid *start, *end;
+   const GLubyte *sizeAddr; /* buffer size, cast to a pointer */
 
    ASSERT(pack->BufferObj->Name != 0);
 
@@ -449,11 +450,13 @@ _mesa_validate_pbo_access(GLuint dimensions,
                               format, type, depth-1, height-1, width);
 
 
-   if ((const GLubyte *) start > (const GLubyte *) pack->BufferObj->Size) {
+   sizeAddr = ((const GLubyte *) 0) + pack->BufferObj->Size;
+
+   if ((const GLubyte *) start > sizeAddr) {
       /* This will catch negative values / wrap-around */
       return GL_FALSE;
    }
-   if ((const GLubyte *) end > (const GLubyte *) pack->BufferObj->Size) {
+   if ((const GLubyte *) end > sizeAddr) {
       /* Image read goes beyond end of buffer */
       return GL_FALSE;
    }
@@ -474,7 +477,7 @@ _mesa_BindBufferARB(GLenum target, GLuint buffer)
 {
    GET_CURRENT_CONTEXT(ctx);
    struct gl_buffer_object *oldBufObj;
-   struct gl_buffer_object *newBufObj = 0;
+   struct gl_buffer_object *newBufObj = NULL;
    ASSERT_OUTSIDE_BEGIN_END(ctx);
 
    oldBufObj = buffer_object_get_target( ctx, target, "BindBufferARB" );
@@ -689,6 +692,7 @@ _mesa_GenBuffersARB(GLsizei n, GLuint *buffer)
       GLenum target = 0;
       bufObj = (*ctx->Driver.NewBufferObject)( ctx, name, target );
       if (!bufObj) {
+         _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
          _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGenBuffersARB");
          return;
       }
@@ -899,7 +903,7 @@ _mesa_GetBufferParameterivARB(GLenum target, GLenum pname, GLint *params)
 
    switch (pname) {
       case GL_BUFFER_SIZE_ARB:
-         *params = bufObj->Size;
+         *params = (GLint) bufObj->Size;
          break;
       case GL_BUFFER_USAGE_ARB:
          *params = bufObj->Usage;