src/sys/security/audit/audit_bsm_db.c
/*
 * Insert a event to class mapping. If the event already exists in the
 * mapping, then replace the mapping with the new one.
 *
 * XXX There is currently no constraints placed on the number of mappings.
 * May want to either limit to a number, or in terms of memory usage.
 */
Insert a event to class mapping. If the event already exists in the
mapping, then replace the mapping with the new one.

XXX There is currently no constraints placed on the number of mappings.
May want to either limit to a number, or in terms of memory usage.
Insert a event to class mapping . If the event already exists in the mapping then replace the mapping with the new one . XXX There is currently no constraints placed on the number of mappings . May want to either limit to a number or in terms of memory usage .
void
au_evclassmap_insert(au_event_t event, au_class_t class)
{
	struct evclass_list *evcl;
	struct evclass_elem *evc, *evc_new;
	evc_new = malloc(sizeof(*evc), M_AUDITEVCLASS, M_WAITOK);
	EVCLASS_WLOCK();
	evcl = &evclass_hash[event % EVCLASSMAP_HASH_TABLE_SIZE];
	LIST_FOREACH(evc, &evcl->head, entry) {
		if (evc->event == event) {
			evc->class = class;
			EVCLASS_WUNLOCK();
			free(evc_new, M_AUDITEVCLASS);
			return;
		}
	}
	evc = evc_new;
	evc->event = event;
	evc->class = class;
	LIST_INSERT_HEAD(&evcl->head, evc, entry);
	EVCLASS_WUNLOCK();
}
void au_evclassmap_insert ( au_event_t event , au_class_t class ) { struct evclass_list * evcl ; struct evclass_elem * evc , * evc_new ; evc_new = malloc ( sizeof ( * evc ) , M_AUDITEVCLASS , M_WAITOK ) ; EVCLASS_WLOCK ( ) ; evcl = & evclass_hash [ event % EVCLASSMAP_HASH_TABLE_SIZE ] ; LIST_FOREACH ( evc , & evcl -> head , entry ) { if ( evc -> event == event ) { evc -> class = class ; EVCLASS_WUNLOCK ( ) ; free ( evc_new , M_AUDITEVCLASS ) ; return ; } } evc = evc_new ; evc -> event = event ; evc -> class = class ; LIST_INSERT_HEAD ( & evcl -> head , evc , entry ) ; EVCLASS_WUNLOCK ( ) ; }
Insert a event to class mapping.
Insert a event to class mapping .
/*
	 * Pessimistically, always allocate storage before acquiring mutex.
	 * Free if there is already a mapping for this event.
	 */