Mesa (master): mesa: Use _mesa_align_malloc in _mesa_buffer_data

Ian Romanick idr at kemper.freedesktop.org
Wed Jan 29 16:17:34 UTC 2014


Module: Mesa
Branch: master
Commit: f772d51c256b9e6458a4f9cf2021eadef34c8313
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=f772d51c256b9e6458a4f9cf2021eadef34c8313

Author: Siavash Eliasi <siavashserver at gmail.com>
Date:   Thu Nov 28 12:44:37 2013 +0330

mesa: Use _mesa_align_malloc in _mesa_buffer_data

v2: Fixed memory leak.

Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>

---

 src/mesa/main/bufferobj.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
index e305038..cde6ac2 100644
--- a/src/mesa/main/bufferobj.c
+++ b/src/mesa/main/bufferobj.c
@@ -560,9 +560,12 @@ _mesa_buffer_data( struct gl_context *ctx, GLenum target, GLsizeiptrARB size,
 {
    void * new_data;
 
-   (void) ctx; (void) target;
+   (void) target;
+
+   if (bufObj->Data)
+      _mesa_align_free( bufObj->Data );
 
-   new_data = _mesa_realloc( bufObj->Data, bufObj->Size, size );
+   new_data = _mesa_align_malloc( size, ctx->Const.MinMapBufferAlignment );
    if (new_data) {
       bufObj->Data = (GLubyte *) new_data;
       bufObj->Size = size;




More information about the mesa-commit mailing list