Mesa (master): util: Remove unused includes and convert to lower-case memory ops

Marek Olšák mareko at kemper.freedesktop.org
Wed Jun 7 19:08:47 UTC 2017


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

Author: Thomas Helland <thomashelland90 at gmail.com>
Date:   Thu Jun  1 22:38:59 2017 +0200

util: Remove unused includes and convert to lower-case memory ops

Also, prepare for the next commit by correcting some coding style
changes. This should be all non-functional changes.

Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Reviewed-by: Eric Engestrom <eric.engestrom at imgtec.com>

---

 src/util/u_dynarray.h | 27 ++++++++++++---------------
 1 file changed, 12 insertions(+), 15 deletions(-)

diff --git a/src/util/u_dynarray.h b/src/util/u_dynarray.h
index 7b7a093d82..9143c5a60d 100644
--- a/src/util/u_dynarray.h
+++ b/src/util/u_dynarray.h
@@ -27,8 +27,7 @@
 #ifndef U_DYNARRAY_H
 #define U_DYNARRAY_H
 
-#include "pipe/p_compiler.h"
-#include "util/u_memory.h"
+#include <stdlib.h>
 
 /* A zero-initialized version of this is guaranteed to represent an
  * empty array.
@@ -52,9 +51,8 @@ util_dynarray_init(struct util_dynarray *buf)
 static inline void
 util_dynarray_fini(struct util_dynarray *buf)
 {
-   if(buf->data)
-   {
-      FREE(buf->data);
+   if (buf->data) {
+      free(buf->data);
       util_dynarray_init(buf);
    }
 }
@@ -63,18 +61,18 @@ util_dynarray_fini(struct util_dynarray *buf)
 static inline void *
 util_dynarray_resize(struct util_dynarray *buf, unsigned newsize)
 {
-   char *p;
-   if(newsize > buf->capacity)
-   {
+   void *p;
+   if (newsize > buf->capacity) {
       unsigned newcap = buf->capacity << 1;
-      if(newsize > newcap)
+      if (newsize > newcap)
 	      newcap = newsize;
-      buf->data = REALLOC(buf->data, buf->capacity, newcap);
+      buf->data = realloc(buf->data, newcap);
       buf->capacity = newcap;
    }
 
-   p = (char *)buf->data + buf->size;
+   p = (void *)((char *)buf->data + buf->size);
    buf->size = newsize;
+
    return p;
 }
 
@@ -89,11 +87,10 @@ util_dynarray_trim(struct util_dynarray *buf)
 {
    if (buf->size != buf->capacity) {
       if (buf->size) {
-         buf->data = REALLOC(buf->data, buf->capacity, buf->size);
+         buf->data = realloc(buf->data, buf->size);
          buf->capacity = buf->size;
-      }
-      else {
-         FREE(buf->data);
+      } else {
+         free(buf->data);
          buf->data = 0;
          buf->capacity = 0;
       }




More information about the mesa-commit mailing list