util: Reset size to zero when failed to allocate buffer.
authorJosé Fonseca <jfonseca@vmware.com>
Fri, 28 Aug 2009 11:52:16 +0000 (12:52 +0100)
committerJosé Fonseca <jfonseca@vmware.com>
Fri, 28 Aug 2009 11:52:31 +0000 (12:52 +0100)
src/gallium/auxiliary/util/u_upload_mgr.c

index c90425f3e54f5acc0428cd87d1ef6ba6fbcf32ad..eb635c9f149cd4a355b78497fc85aa9a8912eb1d 100644 (file)
@@ -123,21 +123,25 @@ static enum pipe_error
 u_upload_alloc_buffer( struct u_upload_mgr *upload,
                        unsigned min_size )
 {
+   unsigned size;
+
    /* Release old buffer, if present:
     */
    u_upload_flush( upload );
 
    /* Allocate a new one: 
     */
-   upload->size = align(MAX2(upload->default_size, min_size), 4096);
+   size = align(MAX2(upload->default_size, min_size), 4096);
 
    upload->buffer = pipe_buffer_create( upload->screen,
                                         upload->alignment,
                                         upload->usage | PIPE_BUFFER_USAGE_CPU_WRITE,
-                                        upload->size );
+                                        size );
    if (upload->buffer == NULL) 
       goto fail;
    
+   upload->size = size;
+
    upload->offset = 0;
    return 0;