diff options
author | Charles Longeau <chl@cvs.openbsd.org> | 2007-09-13 20:40:03 +0000 |
---|---|---|
committer | Charles Longeau <chl@cvs.openbsd.org> | 2007-09-13 20:40:03 +0000 |
commit | decd7804d940b3795410578dbed91acf92181aba (patch) | |
tree | 6f261eedbfc496b563346c5c614b3860c3f9049d | |
parent | 37895f3f9db29c33be21138944b687bc7646aa93 (diff) |
MALLOC/FREE -> malloc/free and M_ZERO changes
ok henning@ krw@ canacar@ ray@
-rw-r--r-- | sys/altq/altq_cbq.c | 7 | ||||
-rw-r--r-- | sys/altq/altq_cdnr.c | 7 | ||||
-rw-r--r-- | sys/altq/altq_hfsc.c | 58 | ||||
-rw-r--r-- | sys/altq/altq_priq.c | 26 | ||||
-rw-r--r-- | sys/altq/altq_red.c | 12 | ||||
-rw-r--r-- | sys/altq/altq_rio.c | 7 | ||||
-rw-r--r-- | sys/altq/altq_rmclass.c | 16 | ||||
-rw-r--r-- | sys/altq/altq_subr.c | 10 |
8 files changed, 61 insertions, 82 deletions
diff --git a/sys/altq/altq_cbq.c b/sys/altq/altq_cbq.c index 16f4b272108..a17eb403de1 100644 --- a/sys/altq/altq_cbq.c +++ b/sys/altq/altq_cbq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: altq_cbq.c,v 1.22 2007/05/28 17:16:38 henning Exp $ */ +/* $OpenBSD: altq_cbq.c,v 1.23 2007/09/13 20:40:02 chl Exp $ */ /* $KAME: altq_cbq.c,v 1.9 2000/12/14 08:12:45 thorpej Exp $ */ /* @@ -214,10 +214,9 @@ cbq_add_altq(struct pf_altq *a) return (ENODEV); /* allocate and initialize cbq_state_t */ - MALLOC(cbqp, cbq_state_t *, sizeof(cbq_state_t), M_DEVBUF, M_WAITOK); + cbqp = malloc(sizeof(cbq_state_t), M_DEVBUF, M_WAITOK|M_ZERO); if (cbqp == NULL) return (ENOMEM); - bzero(cbqp, sizeof(cbq_state_t)); CALLOUT_INIT(&cbqp->cbq_callout); cbqp->cbq_qlen = 0; cbqp->ifnp.ifq_ = &ifp->if_snd; /* keep the ifq */ @@ -245,7 +244,7 @@ cbq_remove_altq(struct pf_altq *a) cbq_class_destroy(cbqp, cbqp->ifnp.root_); /* deallocate cbq_state_t */ - FREE(cbqp, M_DEVBUF); + free(cbqp, M_DEVBUF); return (0); } diff --git a/sys/altq/altq_cdnr.c b/sys/altq/altq_cdnr.c index f26e66626c1..1519958fb96 100644 --- a/sys/altq/altq_cdnr.c +++ b/sys/altq/altq_cdnr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: altq_cdnr.c,v 1.7 2002/12/16 17:27:20 henning Exp $ */ +/* $OpenBSD: altq_cdnr.c,v 1.8 2007/09/13 20:40:02 chl Exp $ */ /* $KAME: altq_cdnr.c,v 1.8 2000/12/14 08:12:45 thorpej Exp $ */ /* @@ -284,10 +284,9 @@ cdnr_cballoc(top, type, input_func) return (NULL); } - MALLOC(cb, struct cdnr_block *, size, M_DEVBUF, M_WAITOK); + cb = malloc(size, M_DEVBUF, M_WAITOK|M_ZERO); if (cb == NULL) return (NULL); - bzero(cb, size); cb->cb_len = size; cb->cb_type = type; @@ -326,7 +325,7 @@ cdnr_cbdestroy(cblock) if (cb->cb_top != cblock) LIST_REMOVE(cb, cb_next); - FREE(cb, M_DEVBUF); + free(cb, M_DEVBUF); } /* diff --git a/sys/altq/altq_hfsc.c b/sys/altq/altq_hfsc.c index a3e73039233..39f25736889 100644 --- a/sys/altq/altq_hfsc.c +++ b/sys/altq/altq_hfsc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: altq_hfsc.c,v 1.24 2007/05/28 17:16:38 henning Exp $ */ +/* $OpenBSD: altq_hfsc.c,v 1.25 2007/09/13 20:40:02 chl Exp $ */ /* $KAME: altq_hfsc.c,v 1.17 2002/11/29 07:48:33 kjc Exp $ */ /* @@ -154,15 +154,13 @@ hfsc_add_altq(struct pf_altq *a) if (!ALTQ_IS_READY(&ifp->if_snd)) return (ENODEV); - MALLOC(hif, struct hfsc_if *, sizeof(struct hfsc_if), - M_DEVBUF, M_WAITOK); + hif = malloc(sizeof(struct hfsc_if), M_DEVBUF, M_WAITOK|M_ZERO); if (hif == NULL) return (ENOMEM); - bzero(hif, sizeof(struct hfsc_if)); hif->hif_eligible = ellist_alloc(); if (hif->hif_eligible == NULL) { - FREE(hif, M_DEVBUF); + free(hif, M_DEVBUF); return (ENOMEM); } @@ -188,7 +186,7 @@ hfsc_remove_altq(struct pf_altq *a) ellist_destroy(hif->hif_eligible); - FREE(hif, M_DEVBUF); + free(hif, M_DEVBUF); return (0); } @@ -349,17 +347,13 @@ hfsc_class_create(struct hfsc_if *hif, struct service_curve *rsc, } #endif - MALLOC(cl, struct hfsc_class *, sizeof(struct hfsc_class), - M_DEVBUF, M_WAITOK); + cl = malloc(sizeof(struct hfsc_class), M_DEVBUF, M_WAITOK|M_ZERO); if (cl == NULL) return (NULL); - bzero(cl, sizeof(struct hfsc_class)); - MALLOC(cl->cl_q, class_queue_t *, sizeof(class_queue_t), - M_DEVBUF, M_WAITOK); + cl->cl_q = malloc(sizeof(class_queue_t), M_DEVBUF, M_WAITOK|M_ZERO); if (cl->cl_q == NULL) goto err_ret; - bzero(cl->cl_q, sizeof(class_queue_t)); cl->cl_actc = actlist_alloc(); if (cl->cl_actc == NULL) @@ -416,8 +410,8 @@ hfsc_class_create(struct hfsc_if *hif, struct service_curve *rsc, #endif /* ALTQ_RED */ if (rsc != NULL && (rsc->m1 != 0 || rsc->m2 != 0)) { - MALLOC(cl->cl_rsc, struct internal_sc *, - sizeof(struct internal_sc), M_DEVBUF, M_WAITOK); + cl->cl_rsc = malloc(sizeof(struct internal_sc), M_DEVBUF, + M_WAITOK); if (cl->cl_rsc == NULL) goto err_ret; sc2isc(rsc, cl->cl_rsc); @@ -425,16 +419,16 @@ hfsc_class_create(struct hfsc_if *hif, struct service_curve *rsc, rtsc_init(&cl->cl_eligible, cl->cl_rsc, 0, 0); } if (fsc != NULL && (fsc->m1 != 0 || fsc->m2 != 0)) { - MALLOC(cl->cl_fsc, struct internal_sc *, - sizeof(struct internal_sc), M_DEVBUF, M_WAITOK); + cl->cl_fsc = malloc(sizeof(struct internal_sc), M_DEVBUF, + M_WAITOK); if (cl->cl_fsc == NULL) goto err_ret; sc2isc(fsc, cl->cl_fsc); rtsc_init(&cl->cl_virtual, cl->cl_fsc, 0, 0); } if (usc != NULL && (usc->m1 != 0 || usc->m2 != 0)) { - MALLOC(cl->cl_usc, struct internal_sc *, - sizeof(struct internal_sc), M_DEVBUF, M_WAITOK); + cl->cl_usc = malloc(sizeof(struct internal_sc), M_DEVBUF, + M_WAITOK); if (cl->cl_usc == NULL) goto err_ret; sc2isc(usc, cl->cl_usc); @@ -503,14 +497,14 @@ hfsc_class_create(struct hfsc_if *hif, struct service_curve *rsc, #endif } if (cl->cl_fsc != NULL) - FREE(cl->cl_fsc, M_DEVBUF); + free(cl->cl_fsc, M_DEVBUF); if (cl->cl_rsc != NULL) - FREE(cl->cl_rsc, M_DEVBUF); + free(cl->cl_rsc, M_DEVBUF); if (cl->cl_usc != NULL) - FREE(cl->cl_usc, M_DEVBUF); + free(cl->cl_usc, M_DEVBUF); if (cl->cl_q != NULL) - FREE(cl->cl_q, M_DEVBUF); - FREE(cl, M_DEVBUF); + free(cl->cl_q, M_DEVBUF); + free(cl, M_DEVBUF); return (NULL); } @@ -574,13 +568,13 @@ hfsc_class_destroy(struct hfsc_class *cl) cl->cl_hif->hif_defaultclass = NULL; if (cl->cl_usc != NULL) - FREE(cl->cl_usc, M_DEVBUF); + free(cl->cl_usc, M_DEVBUF); if (cl->cl_fsc != NULL) - FREE(cl->cl_fsc, M_DEVBUF); + free(cl->cl_fsc, M_DEVBUF); if (cl->cl_rsc != NULL) - FREE(cl->cl_rsc, M_DEVBUF); - FREE(cl->cl_q, M_DEVBUF); - FREE(cl, M_DEVBUF); + free(cl->cl_rsc, M_DEVBUF); + free(cl->cl_q, M_DEVBUF); + free(cl, M_DEVBUF); return (0); } @@ -1107,7 +1101,7 @@ ellist_alloc(void) { ellist_t *head; - MALLOC(head, ellist_t *, sizeof(ellist_t), M_DEVBUF, M_WAITOK); + head = malloc(sizeof(ellist_t), M_DEVBUF, M_WAITOK); TAILQ_INIT(head); return (head); } @@ -1115,7 +1109,7 @@ ellist_alloc(void) static void ellist_destroy(ellist_t *head) { - FREE(head, M_DEVBUF); + free(head, M_DEVBUF); } static void @@ -1210,7 +1204,7 @@ actlist_alloc(void) { actlist_t *head; - MALLOC(head, actlist_t *, sizeof(actlist_t), M_DEVBUF, M_WAITOK); + head = malloc(sizeof(actlist_t), M_DEVBUF, M_WAITOK); TAILQ_INIT(head); return (head); } @@ -1218,7 +1212,7 @@ actlist_alloc(void) static void actlist_destroy(actlist_t *head) { - FREE(head, M_DEVBUF); + free(head, M_DEVBUF); } static void actlist_insert(struct hfsc_class *cl) diff --git a/sys/altq/altq_priq.c b/sys/altq/altq_priq.c index 25e8a8beebc..37de8bf1cf3 100644 --- a/sys/altq/altq_priq.c +++ b/sys/altq/altq_priq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: altq_priq.c,v 1.20 2007/05/28 17:16:38 henning Exp $ */ +/* $OpenBSD: altq_priq.c,v 1.21 2007/09/13 20:40:02 chl Exp $ */ /* $KAME: altq_priq.c,v 1.1 2000/10/18 09:15:23 kjc Exp $ */ /* * Copyright (C) 2000 @@ -93,11 +93,9 @@ priq_add_altq(struct pf_altq *a) if (!ALTQ_IS_READY(&ifp->if_snd)) return (ENODEV); - MALLOC(pif, struct priq_if *, sizeof(struct priq_if), - M_DEVBUF, M_WAITOK); + pif = malloc(sizeof(struct priq_if), M_DEVBUF, M_WAITOK|M_ZERO); if (pif == NULL) return (ENOMEM); - bzero(pif, sizeof(struct priq_if)); pif->pif_bandwidth = a->ifbandwidth; pif->pif_maxpri = -1; pif->pif_ifq = &ifp->if_snd; @@ -119,7 +117,7 @@ priq_remove_altq(struct pf_altq *a) (void)priq_clear_interface(pif); - FREE(pif, M_DEVBUF); + free(pif, M_DEVBUF); return (0); } @@ -266,17 +264,15 @@ priq_class_create(struct priq_if *pif, int pri, int qlimit, int flags, int qid) red_destroy(cl->cl_red); #endif } else { - MALLOC(cl, struct priq_class *, sizeof(struct priq_class), - M_DEVBUF, M_WAITOK); + cl = malloc(sizeof(struct priq_class), M_DEVBUF, + M_WAITOK|M_ZERO); if (cl == NULL) return (NULL); - bzero(cl, sizeof(struct priq_class)); - MALLOC(cl->cl_q, class_queue_t *, sizeof(class_queue_t), - M_DEVBUF, M_WAITOK); + cl->cl_q = malloc(sizeof(class_queue_t), M_DEVBUF, + M_WAITOK|M_ZERO); if (cl->cl_q == NULL) goto err_ret; - bzero(cl->cl_q, sizeof(class_queue_t)); } pif->pif_classes[pri] = cl; @@ -343,8 +339,8 @@ priq_class_create(struct priq_if *pif, int pri, int qlimit, int flags, int qid) #endif } if (cl->cl_q != NULL) - FREE(cl->cl_q, M_DEVBUF); - FREE(cl, M_DEVBUF); + free(cl->cl_q, M_DEVBUF); + free(cl, M_DEVBUF); return (NULL); } @@ -382,8 +378,8 @@ priq_class_destroy(struct priq_class *cl) red_destroy(cl->cl_red); #endif } - FREE(cl->cl_q, M_DEVBUF); - FREE(cl, M_DEVBUF); + free(cl->cl_q, M_DEVBUF); + free(cl, M_DEVBUF); return (0); } diff --git a/sys/altq/altq_red.c b/sys/altq/altq_red.c index 92ee7b6fbbb..21ef242eed3 100644 --- a/sys/altq/altq_red.c +++ b/sys/altq/altq_red.c @@ -1,4 +1,4 @@ -/* $OpenBSD: altq_red.c,v 1.13 2007/05/28 17:16:38 henning Exp $ */ +/* $OpenBSD: altq_red.c,v 1.14 2007/09/13 20:40:02 chl Exp $ */ /* $KAME: altq_red.c,v 1.10 2002/04/03 05:38:51 kjc Exp $ */ /* @@ -162,10 +162,9 @@ red_alloc(int weight, int inv_pmax, int th_min, int th_max, int flags, int w, i; int npkts_per_sec; - MALLOC(rp, red_t *, sizeof(red_t), M_DEVBUF, M_WAITOK); + rp = malloc(sizeof(red_t), M_DEVBUF, M_WAITOK|M_ZERO); if (rp == NULL) return (NULL); - bzero(rp, sizeof(red_t)); rp->red_avg = 0; rp->red_idle = 1; @@ -244,7 +243,7 @@ void red_destroy(red_t *rp) { wtab_destroy(rp->red_wtab); - FREE(rp, M_DEVBUF); + free(rp, M_DEVBUF); } void @@ -534,10 +533,9 @@ wtab_alloc(int weight) return (w); } - MALLOC(w, struct wtab *, sizeof(struct wtab), M_DEVBUF, M_WAITOK); + w = malloc(sizeof(struct wtab), M_DEVBUF, M_WAITOK|M_ZERO); if (w == NULL) panic("wtab_alloc: malloc failed!"); - bzero(w, sizeof(struct wtab)); w->w_weight = weight; w->w_refcount = 1; w->w_next = wtab_list; @@ -570,7 +568,7 @@ wtab_destroy(struct wtab *w) break; } - FREE(w, M_DEVBUF); + free(w, M_DEVBUF); return (0); } diff --git a/sys/altq/altq_rio.c b/sys/altq/altq_rio.c index 0846c2cf288..92bfda614ae 100644 --- a/sys/altq/altq_rio.c +++ b/sys/altq/altq_rio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: altq_rio.c,v 1.10 2007/06/17 19:58:58 jasper Exp $ */ +/* $OpenBSD: altq_rio.c,v 1.11 2007/09/13 20:40:02 chl Exp $ */ /* $KAME: altq_rio.c,v 1.8 2000/12/14 08:12:46 thorpej Exp $ */ /* @@ -172,10 +172,9 @@ rio_alloc(int weight, struct redparams *params, int flags, int pkttime) int w, i; int npkts_per_sec; - MALLOC(rp, rio_t *, sizeof(rio_t), M_DEVBUF, M_WAITOK); + rp = malloc(sizeof(rio_t), M_DEVBUF, M_WAITOK|M_ZERO); if (rp == NULL) return (NULL); - bzero(rp, sizeof(rio_t)); rp->rio_flags = flags; if (pkttime == 0) @@ -259,7 +258,7 @@ void rio_destroy(rio_t *rp) { wtab_destroy(rp->rio_wtab); - FREE(rp, M_DEVBUF); + free(rp, M_DEVBUF); } void diff --git a/sys/altq/altq_rmclass.c b/sys/altq/altq_rmclass.c index 6f4c6bdbaa2..de55447a9f9 100644 --- a/sys/altq/altq_rmclass.c +++ b/sys/altq/altq_rmclass.c @@ -1,4 +1,4 @@ -/* $OpenBSD: altq_rmclass.c,v 1.12 2006/03/04 22:40:15 brad Exp $ */ +/* $OpenBSD: altq_rmclass.c,v 1.13 2007/09/13 20:40:02 chl Exp $ */ /* $KAME: altq_rmclass.c,v 1.10 2001/02/09 07:20:40 kjc Exp $ */ /* @@ -200,19 +200,15 @@ rmc_newclass(int pri, struct rm_ifdat *ifd, u_int nsecPerByte, } #endif - MALLOC(cl, struct rm_class *, sizeof(struct rm_class), - M_DEVBUF, M_WAITOK); + cl = malloc(sizeof(struct rm_class), M_DEVBUF, M_WAITOK|M_ZERO); if (cl == NULL) return (NULL); - bzero(cl, sizeof(struct rm_class)); CALLOUT_INIT(&cl->callout_); - MALLOC(cl->q_, class_queue_t *, sizeof(class_queue_t), - M_DEVBUF, M_WAITOK); + cl->q_ = malloc(sizeof(class_queue_t), M_DEVBUF, M_WAITOK|M_ZERO); if (cl->q_ == NULL) { - FREE(cl, M_DEVBUF); + free(cl, M_DEVBUF); return (NULL); } - bzero(cl->q_, sizeof(class_queue_t)); /* * Class initialization. @@ -620,8 +616,8 @@ rmc_delete_class(struct rm_ifdat *ifd, struct rm_class *cl) red_destroy(cl->red_); #endif } - FREE(cl->q_, M_DEVBUF); - FREE(cl, M_DEVBUF); + free(cl->q_, M_DEVBUF); + free(cl, M_DEVBUF); } diff --git a/sys/altq/altq_subr.c b/sys/altq/altq_subr.c index 203e00557b7..fc9d41382c6 100644 --- a/sys/altq/altq_subr.c +++ b/sys/altq/altq_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: altq_subr.c,v 1.21 2006/12/20 17:50:40 gwk Exp $ */ +/* $OpenBSD: altq_subr.c,v 1.22 2007/09/13 20:40:02 chl Exp $ */ /* $KAME: altq_subr.c,v 1.11 2002/01/11 08:11:49 kjc Exp $ */ /* @@ -275,15 +275,13 @@ tbr_set(ifq, profile) if ((tbr = ifq->altq_tbr) == NULL) return (ENOENT); ifq->altq_tbr = NULL; - FREE(tbr, M_DEVBUF); + free(tbr, M_DEVBUF); return (0); } - MALLOC(tbr, struct tb_regulator *, sizeof(struct tb_regulator), - M_DEVBUF, M_WAITOK); + tbr = malloc(sizeof(struct tb_regulator), M_DEVBUF, M_WAITOK|M_ZERO); if (tbr == NULL) return (ENOMEM); - bzero(tbr, sizeof(struct tb_regulator)); tbr->tbr_rate = TBR_SCALE(profile->rate / 8) / machclk_freq; tbr->tbr_depth = TBR_SCALE(profile->depth); @@ -299,7 +297,7 @@ tbr_set(ifq, profile) ifq->altq_tbr = tbr; /* set the new tbr */ if (otbr != NULL) - FREE(otbr, M_DEVBUF); + free(otbr, M_DEVBUF); else { if (tbr_timer == 0) { CALLOUT_RESET(&tbr_callout, 1, tbr_timeout, (void *)0); |