RFC sample illustrating conversion of multi-dimensional VLA to use
alloca().

Signed-off-by: Tyler Retzlaff <roret...@linux.microsoft.com>
---
 lib/dispatcher/rte_dispatcher.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/dispatcher/rte_dispatcher.c b/lib/dispatcher/rte_dispatcher.c
index 7934917..f154c26 100644
--- a/lib/dispatcher/rte_dispatcher.c
+++ b/lib/dispatcher/rte_dispatcher.c
@@ -119,7 +119,7 @@ struct rte_dispatcher {
        struct rte_event *events, uint16_t num_events)
 {
        int i;
-       struct rte_event bursts[EVD_MAX_HANDLERS][num_events];
+       struct rte_event *bursts = alloca(sizeof(struct rte_event) * 
EVD_MAX_HANDLERS * num_events);
        uint16_t burst_lens[EVD_MAX_HANDLERS] = { 0 };
        uint16_t drop_count = 0;
        uint16_t dispatch_count;
@@ -136,7 +136,7 @@ struct rte_dispatcher {
                        continue;
                }
 
-               bursts[handler_idx][burst_lens[handler_idx]] = *event;
+               bursts[handler_idx * num_events + burst_lens[handler_idx]] = 
*event;
                burst_lens[handler_idx]++;
        }
 
@@ -152,7 +152,7 @@ struct rte_dispatcher {
                        continue;
 
                handler->process_fun(dispatcher->event_dev_id, port->port_id,
-                                    bursts[i], len, handler->process_data);
+                                    &bursts[i * num_events], len, 
handler->process_data);
 
                dispatched += len;
 
-- 
1.8.3.1

Reply via email to