Commit 6cfa69aa authored by Daniel Salzman's avatar Daniel Salzman

Merge branch 'mempattern-api' into 'master'

mempattern: correct api usage on several places

See merge request !785
parents 0773f534 525db5bd
......@@ -249,15 +249,15 @@ static void *udp_recvmmsg_init(void)
knot_mm_t mm;
mm_ctx_mempool(&mm, sizeof(struct udp_recvmmsg));
struct udp_recvmmsg *rq = mm.alloc(mm.ctx, sizeof(struct udp_recvmmsg));
struct udp_recvmmsg *rq = mm_alloc(&mm, sizeof(struct udp_recvmmsg));
memset(rq, 0, sizeof(*rq));
memcpy(&rq->mm, &mm, sizeof(knot_mm_t));
/* Initialize buffers. */
for (unsigned i = 0; i < NBUFS; ++i) {
rq->iobuf[i] = mm.alloc(mm.ctx, KNOT_WIRE_MAX_PKTSIZE * RECVMMSG_BATCHLEN);
rq->iov[i] = mm.alloc(mm.ctx, sizeof(struct iovec) * RECVMMSG_BATCHLEN);
rq->msgs[i] = mm.alloc(mm.ctx, sizeof(struct mmsghdr) * RECVMMSG_BATCHLEN);
rq->iobuf[i] = mm_alloc(&mm, KNOT_WIRE_MAX_PKTSIZE * RECVMMSG_BATCHLEN);
rq->iov[i] = mm_alloc(&mm, sizeof(struct iovec) * RECVMMSG_BATCHLEN);
rq->msgs[i] = mm_alloc(&mm, sizeof(struct mmsghdr) * RECVMMSG_BATCHLEN);
memset(rq->msgs[i], 0, sizeof(struct mmsghdr) * RECVMMSG_BATCHLEN);
for (unsigned k = 0; k < RECVMMSG_BATCHLEN; ++k) {
rq->iov[i][k].iov_base = rq->iobuf[i] + k * KNOT_WIRE_MAX_PKTSIZE;
......
......@@ -42,7 +42,7 @@ knot_zonedb_t *knot_zonedb_new(uint32_t size)
/* Create memory pool context. */
knot_mm_t mm = {0};
mm_ctx_mempool(&mm, MM_DEFAULT_BLKSIZE);
knot_zonedb_t *db = mm.alloc(mm.ctx, sizeof(knot_zonedb_t));
knot_zonedb_t *db = mm_alloc(&mm, sizeof(knot_zonedb_t));
if (db == NULL) {
return NULL;
}
......@@ -50,7 +50,7 @@ knot_zonedb_t *knot_zonedb_new(uint32_t size)
db->maxlabels = 0;
db->hash = hhash_create_mm((size + 1) * 2, &mm);
if (db->hash == NULL) {
mm.free(db);
mm_free(&mm, db);
return NULL;
}
......
......@@ -83,7 +83,7 @@ static int pkt_wire_alloc(knot_pkt_t *pkt, uint16_t len)
assert(pkt);
assert(len >= KNOT_WIRE_HEADER_SIZE);
pkt->wire = pkt->mm.alloc(pkt->mm.ctx, len);
pkt->wire = mm_alloc(&pkt->mm, len);
if (pkt->wire == NULL) {
return KNOT_ENOMEM;
}
......@@ -392,10 +392,10 @@ void knot_pkt_free(knot_pkt_t **pkt)
// free the space for wireformat
if ((*pkt)->flags & KNOT_PF_FREE) {
(*pkt)->mm.free((*pkt)->wire);
mm_free(&(*pkt)->mm, (*pkt)->wire);
}
(*pkt)->mm.free(*pkt);
mm_free(&(*pkt)->mm, *pkt);
*pkt = NULL;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment