CARS
|
00001 00010 /* Copyright (C) 2011 Nicola Corti 00011 00012 This program is free software: you can redistribute it and/or modify 00013 it under the terms of the GNU General Public License as published by 00014 the Free Software Foundation, either version 3 of the License, or 00015 (at your option) any later version. 00016 00017 This program is distributed in the hope that it will be useful, 00018 but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00020 GNU General Public License for more details. 00021 00022 You should have received a copy of the GNU General Public License 00023 along with this program. If not, see <http://www.gnu.org/licenses/>. 00024 00025 For further information, Nicola Corti - <cortin [at] cli.di.unipi.it> 00026 */ 00027 00028 #ifndef __MACROS_H 00029 #define __MACROS_H 00030 00031 #include <stdlib.h> 00032 #include <errno.h> 00033 00034 00050 #define MALLOC_ERRNO(dest, number, elem, flag, correctvalue, falsevalue)\ 00051 if ((flag) == (correctvalue))\ 00052 { \ 00053 if(((dest) = malloc((number) * sizeof(elem))) == NULL)\ 00054 {errno = ENOMEM; (flag) = (falsevalue);}\ 00055 } 00056 00057 00058 00059 00060 /* ====== NOTA ====== 00061 00062 Per convenzione, la variabile flag per la MALLOC_ERRNO si chiamera' "mem_flag" 00063 00064 Come valore correct consideriamo 0, e come falsevalue consideriamo 1 00065 00066 Questo al fine di agevolare la leggibilita' del codice 00067 */ 00068 00069 00070 #endif