[Mesa-dev] [PATCH 1/4] gallium/util: use standard malloc/calloc/free in u_queue.c

Timothy Arceri tarceri at itsqueeze.com
Wed Mar 8 04:36:31 UTC 2017


This will help us moving the file to the shared src/util dir.
---
 src/gallium/auxiliary/util/u_queue.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_queue.c b/src/gallium/auxiliary/util/u_queue.c
index 05ffc3e..e0ec290 100644
--- a/src/gallium/auxiliary/util/u_queue.c
+++ b/src/gallium/auxiliary/util/u_queue.c
@@ -18,21 +18,20 @@
  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  * USE OR OTHER DEALINGS IN THE SOFTWARE.
  *
  * The above copyright notice and this permission notice (including the
  * next paragraph) shall be included in all copies or substantial portions
  * of the Software.
  */
 
 #include "u_queue.h"
-#include "u_memory.h"
 #include "util/u_string.h"
 
 static void util_queue_killall_and_wait(struct util_queue *queue);
 
 /****************************************************************************
  * Wait for all queues to assert idle when exit() is called.
  *
  * Otherwise, C++ static variable destructors can be called while threads
  * are using the static variables.
  */
@@ -133,21 +132,21 @@ struct thread_input {
    struct util_queue *queue;
    int thread_index;
 };
 
 static int
 util_queue_thread_func(void *input)
 {
    struct util_queue *queue = ((struct thread_input*)input)->queue;
    int thread_index = ((struct thread_input*)input)->thread_index;
 
-   FREE(input);
+   free(input);
 
    if (queue->name) {
       char name[16];
       util_snprintf(name, sizeof(name), "%s:%i", queue->name, thread_index);
       pipe_thread_setname(name);
    }
 
    while (1) {
       struct util_queue_job job;
 
@@ -199,67 +198,68 @@ util_queue_init(struct util_queue *queue,
                 unsigned num_threads)
 {
    unsigned i;
 
    memset(queue, 0, sizeof(*queue));
    queue->name = name;
    queue->num_threads = num_threads;
    queue->max_jobs = max_jobs;
 
    queue->jobs = (struct util_queue_job*)
-                 CALLOC(max_jobs, sizeof(struct util_queue_job));
+                 calloc(max_jobs, sizeof(struct util_queue_job));
    if (!queue->jobs)
       goto fail;
 
    (void) mtx_init(&queue->lock, mtx_plain);
 
    queue->num_queued = 0;
    cnd_init(&queue->has_queued_cond);
    cnd_init(&queue->has_space_cond);
 
-   queue->threads = (thrd_t*)CALLOC(num_threads, sizeof(thrd_t));
+   queue->threads = (thrd_t*) calloc(num_threads, sizeof(thrd_t));
    if (!queue->threads)
       goto fail;
 
    /* start threads */
    for (i = 0; i < num_threads; i++) {
-      struct thread_input *input = MALLOC_STRUCT(thread_input);
+      struct thread_input *input =
+         (struct thread_input *) malloc(sizeof(struct thread_input));
       input->queue = queue;
       input->thread_index = i;
 
       queue->threads[i] = pipe_thread_create(util_queue_thread_func, input);
 
       if (!queue->threads[i]) {
-         FREE(input);
+         free(input);
 
          if (i == 0) {
             /* no threads created, fail */
             goto fail;
          } else {
             /* at least one thread created, so use it */
             queue->num_threads = i;
             break;
          }
       }
    }
 
    add_to_atexit_list(queue);
    return true;
 
 fail:
-   FREE(queue->threads);
+   free(queue->threads);
 
    if (queue->jobs) {
       cnd_destroy(&queue->has_space_cond);
       cnd_destroy(&queue->has_queued_cond);
       mtx_destroy(&queue->lock);
-      FREE(queue->jobs);
+      free(queue->jobs);
    }
    /* also util_queue_is_initialized can be used to check for success */
    memset(queue, 0, sizeof(*queue));
    return false;
 }
 
 static void
 util_queue_killall_and_wait(struct util_queue *queue)
 {
    unsigned i;
@@ -277,22 +277,22 @@ util_queue_killall_and_wait(struct util_queue *queue)
 
 void
 util_queue_destroy(struct util_queue *queue)
 {
    util_queue_killall_and_wait(queue);
    remove_from_atexit_list(queue);
 
    cnd_destroy(&queue->has_space_cond);
    cnd_destroy(&queue->has_queued_cond);
    mtx_destroy(&queue->lock);
-   FREE(queue->jobs);
-   FREE(queue->threads);
+   free(queue->jobs);
+   free(queue->threads);
 }
 
 void
 util_queue_add_job(struct util_queue *queue,
                    void *job,
                    struct util_queue_fence *fence,
                    util_queue_execute_func execute,
                    util_queue_execute_func cleanup)
 {
    struct util_queue_job *ptr;
-- 
2.9.3



More information about the mesa-dev mailing list