xref: /petsc/include/petsc.h (revision 8c819ef214cd8c0b6bd3ceeeb0404fcd3864b7e9)
1 
2 #if !defined(__PETSC_PACKAGE)
3 #define __PETSC_PACKAGE
4 
5 /*  Macros for getting and freeing memory */
6 #define NEW(a)          (a *) MALLOC(sizeof(a))
7 #define MALLOC(a)       malloc(a)
8 #define FREE(a)         free(a)
9 #define MEMCPY(a,b,n)   memcpy((char*)(a),(char*)(b),n)
10 
11 /*  Macros for error checking */
12 #define SETERR(n,s)     {return PetscErrorHandler(__LINE__,__FILE__,s,n);}
13 #define CHKERR(n)       {if (n) SETERR(n,(char *)0);}
14 #define CHKPTR(p)       if (!p) SETERR(1,"No memory");
15 
16 
17 typedef struct _PetscObject PetscObject;
18 
19 /*  Useful Petsc functions */
20 
21 #ifdef ANSI_ARG
22 #undef ANSI_ARG
23 #endif
24 #ifdef __STDC__
25 #define ANSI_ARGS(a) a
26 #else
27 #define ANSI_ARGS(a) ()
28 #endif
29 
30 extern int PetscDestroy       ANSI_ARGS((PetscObject));
31 extern int PetscErrorHandler  ANSI_ARGS((int,char*,char*,int));
32 
33 #endif
34