xref: /freebsd/contrib/ofed/libibverbs/alloca.h (revision 42249ef2)
1 #ifndef _LIBIBVERBS_ALLOCA_H_
2 #define	_LIBIBVERBS_ALLOCA_H_
3 #include <stdlib.h>
4 #include <string.h>
5 #include <stdlib.h>
6 
7 #define	strdupa(_s)						\
8 ({								\
9 	char *_d;						\
10 	int _len;						\
11 								\
12 	_len = strlen(_s) + 1;					\
13 	_d = alloca(_len);					\
14 	if (_d)							\
15 		memcpy(_d, _s, _len);				\
16 	_d;							\
17 })
18 #endif	/* _LIBIBVERBS_ALLOCA_H_ */
19