root/software/fss-parallel-tools/malloc.h @ a1fcfb60
| 7e8045d8 | David Sorber | /**
|
|
* Copyright © 2019, Oracle and/or its affiliates. All rights reserved.
|
|||
*
|
|||
* Licensed under the Universal Permissive License v 1.0 as shown at
|
|||
* http://oss.oracle.com/licenses/upl
|
|||
*
|
|||
*/
|
|||
#ifndef MALLOC_H
|
|||
#define MALLOC_H
|
|||
#include <stdlib.h>
|
|||
// Suitable for doing:
|
|||
// struct foo *MALLOC(v); // make something that foo can point at.
|
|||
#define MALLOC(v) v = malloc(sizeof (*v))
|
|||
// Suitable for doing:
|
|||
// struct foo *MALLOC_N(v, 5); // make an array of 5 "struct foo"s.
|
|||
#define MALLOC_N(v, n) v = malloc(sizeof(*v)*(n))
|
|||
#define REALLOC(v, n) v = realloc(v, (n)*sizeof(*v))
|
|||
#define FREE(v) (free(v), (v) = NULL)
|
|||
#endif
|