FreeBSD/usr.sbin/bsnmpd/tools/libbsnmptools/bsnmpmap.c
/*
 * Given a number and string, allocate memory for a (int, string) pair and add
 * it to the given oid2str mapping entry's enum pairs list.
 */
Given a number and string, allocate memory for a (int, string) pair and add
it to the given oid2str mapping entry's enum pairs list.
Given a number and string allocate memory for a ( int string ) pair and add it to the given oid2str mapping entry ' s enum pairs list .
int32_t
enum_pair_insert(struct enum_pairs *headp, int32_t enum_val, char *enum_str)
{
	struct enum_pair *e_new;
	if ((e_new = calloc(1, sizeof(struct enum_pair))) == NULL) {
		syslog(LOG_ERR, "calloc() failed: %s", strerror(errno));
		return (-1);
	}
	if ((e_new->enum_str = strdup(enum_str)) == NULL) {
		syslog(LOG_ERR, "strdup() failed: %s", strerror(errno));
		free(e_new);
		return (-1);
	}
	e_new->enum_val = enum_val;
	STAILQ_INSERT_TAIL(headp, e_new, link);
	return (1);
}
int32_t enum_pair_insert ( struct enum_pairs * headp , int32_t enum_val , char * enum_str ) { struct enum_pair * e_new ; if ( ( e_new = calloc ( 1 , sizeof ( struct enum_pair ) ) ) == NULL ) { syslog ( LOG_ERR , " " , strerror ( errno ) ) ; return ( -1 ) ; } if ( ( e_new -> enum_str = strdup ( enum_str ) ) == NULL ) { syslog ( LOG_ERR , " " , strerror ( errno ) ) ; free ( e_new ) ; return ( -1 ) ; } e_new -> enum_val = enum_val ; STAILQ_INSERT_TAIL ( headp , e_new , link ) ; return ( 1 ) ; }
Given a number and string, allocate memory for a (int, string) pair and add
 it to the given oid2str mapping entry's enum pairs list.
Given a number and string allocate memory for a ( int string ) pair and add it to the given oid2str mapping entry ' s enum pairs list .