|
|
00060 void *xcalloc PARAMS ((size_t n, size_t s));
00061 void *xrealloc PARAMS ((void *p, size_t n));
00062 char *xstrdup PARAMS ((const char *str));
00063
00064 # define XMALLOC(Type, N_items) ((Type *) xmalloc (sizeof (Type) * (N_items)))
00065 # define XCALLOC(Type, N_items) ((Type *) xcalloc (sizeof (Type), (N_items)))
00066 # define XREALLOC(Ptr, Type, N_items) \
00067 ((Type *) xrealloc ((void *) (Ptr), sizeof (Type) * (N_items)))
00068
00069 /* Declare and alloc memory for VAR of type TYPE. */
00070 # define NEW(Type, Var) Type *(Var) = XMALLOC (Type, 1)
00071
00072 /* Free VAR only if non NULL. */
00073 # define XFREE(Var) \
00074 do { \
00075 if (Var) \
00076 free (Var); \
00077 } while (0)
00078
00079 /* Return a pointer to a malloc'ed copy of the array SRC of NUM elements. */
00080 # define CCLONE(Src, Num) \
00081 (memcpy (xmalloc (sizeof (*Src) * (Num)), (Src), sizeof (*Src) * (Num)))
00082
00083 /* Return a malloc'ed copy of SRC. */
00084 # define CLONE(Src) CCLONE (Src, 1)
00085
00086
00087 #endif /* !XALLOC_H_ */
求一个简单一点的命令,谢谢大家。 |
|