Change in gapk[master]: procqueue.c: rely on item type instead of its position

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Vadim Yanitskiy gerrit-no-reply at lists.osmocom.org
Fri Jun 29 18:52:23 UTC 2018


Vadim Yanitskiy has submitted this change and it was merged. ( https://gerrit.osmocom.org/9785 )

Change subject: procqueue.c: rely on item type instead of its position
......................................................................

procqueue.c: rely on item type instead of its position

In the osmo_gapk_pq_prepare() we do allocate an item's buffer
conditionally, only when its type is not sink, because an output
buffer is not required for sink.

Let's use a bit more elegant way to check, whether item is sink.

Change-Id: I770a1d02273d9d8301a9e4ec72426fb8f4060277
---
M src/procqueue.c
1 file changed, 15 insertions(+), 13 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Vadim Yanitskiy: Verified



diff --git a/src/procqueue.c b/src/procqueue.c
index 78dee4d..28ad1cf 100644
--- a/src/procqueue.c
+++ b/src/procqueue.c
@@ -159,25 +159,27 @@
 osmo_gapk_pq_prepare(struct osmo_gapk_pq *pq)
 {
 	struct osmo_gapk_pq_item *item;
+	unsigned int buf_size;
 
 	/* Iterate over all items in queue */
 	llist_for_each_entry(item, &pq->items, list) {
 		/* The sink item doesn't require an output buffer */
-		if (item->list.next != &pq->items) {
-			unsigned int buf_size = item->len_out;
+		if (item->type == OSMO_GAPK_ITEM_TYPE_SINK)
+			continue;
 
-			/**
-			 * Use maximum known buffer size
-			 * for variable-length codec output
-			 */
-			if (!buf_size)
-				buf_size = VAR_BUF_SIZE;
+		buf_size = item->len_out;
 
-			/* Allocate memory for an output buffer */
-			item->buf = talloc_named_const(item, buf_size, ".buffer");
-			if (!item->buf)
-				return -ENOMEM;
-		}
+		/**
+		 * Use maximum known buffer size
+		 * for variable-length codec output
+		 */
+		if (!buf_size)
+			buf_size = VAR_BUF_SIZE;
+
+		/* Allocate memory for an output buffer */
+		item->buf = talloc_named_const(item, buf_size, ".buffer");
+		if (!item->buf)
+			return -ENOMEM;
 	}
 
 	return 0;

-- 
To view, visit https://gerrit.osmocom.org/9785
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: gapk
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I770a1d02273d9d8301a9e4ec72426fb8f4060277
Gerrit-Change-Number: 9785
Gerrit-PatchSet: 1
Gerrit-Owner: Vadim Yanitskiy <axilirator at gmail.com>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Vadim Yanitskiy <axilirator at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180629/64279aeb/attachment.htm>


More information about the gerrit-log mailing list