1 //===--- mem.h --------------------------------------------------------------=== 2 // 3 // satoko: Satisfiability solver 4 // 5 // This file is distributed under the BSD 2-Clause License. 6 // See LICENSE for details. 7 // 8 //===------------------------------------------------------------------------=== 9 #ifndef satoko__utils__mem_h 10 #define satoko__utils__mem_h 11 12 #include <stdlib.h> 13 14 #include "misc/util/abc_global.h" 15 ABC_NAMESPACE_HEADER_START 16 17 #define satoko_alloc(type, n_elements) ((type *) malloc((n_elements) * sizeof(type))) 18 #define satoko_calloc(type, n_elements) ((type *) calloc((n_elements), sizeof(type))) 19 #define satoko_realloc(type, ptr, n_elements) ((type *) realloc(ptr, (n_elements) * sizeof(type))) 20 #define satoko_free(p) do { free(p); p = NULL; } while(0) 21 22 ABC_NAMESPACE_HEADER_END 23 #endif 24