Merge remote-tracking branch 'origin/release-v4.5.2'
[WRF.git] / var / da / makedepf90-2.8.8 / macro.c
blob38654218fd8dfc766827cc87aa476a47bde81348
1 /*
2 * Copyright (C) 2000-2005 Erik Edelmann <Erik.Edelmann@iki.fi>
4 * This program is free software; you can redistribute it
5 * and/or modify it under the terms of the GNU General Public
6 * License version 2 as published by the Free Software
7 * Foundation.
9 * This program is distributed in the hope that it will be
10 * useful, but WITHOUT ANY WARRANTY; without even the implied
11 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 * PURPOSE. See the GNU General Public License for more
13 * details.
15 * You should have received a copy of the GNU General Public
16 * License along with this program; if not, write to the Free
17 * Software Foundation, Inc., 59 Temple Place, Suite 330,
18 * Boston, MA 02111-1307 USA
21 #include <string.h>
22 #include <assert.h>
23 #include "macro.h"
24 #include "xmalloc.h"
25 #include "global.h"
28 Macro *macro_new ()
30 Macro *m;
32 m = (Macro *) xmalloc (sizeof(Macro));
33 m->name = NULL;
35 return m;
39 void macro_free (Macro *m)
41 assert (m);
42 if (m->name) free (m->name);
43 free (m);
47 void macro_copy (Macro *dst, const Macro *src)
49 assert (dst);
50 assert (src);
52 if (dst->name) free (dst->name);
53 dst->name = xstrdup (src->name);
57 int macrocmp (const void *m1, const void *m2)
59 return strcmp (((Macro *)m1)->name, ((Macro *)m2)->name);
62 void macro_setname (Macro *m, const char *n)
64 if (m->name) free (m->name);
65 m->name = xstrdup(n);