On 06/05, Li, Xiaoyun wrote: >Hi >> > I noticed that there are two allocations, one for pkts_recv[0] and another >> > for >> > pkts_recv[0]->buf_addr, How about we declare >> > >> > struct rte_rawdev_buf pkts_recv[1]; >> > >> > and allocate memory for its buf_addr >> > >> > pkts_recv[0].buf_addr = malloc(size); >> > >> > then we call >> > >> > rte_rawdev_dequeue_buffers(dev_id, &pkts_recv, 1, (void *)size); >> > >> > After that, we just need to free once. >> > >> > free(pkts_recv[0].buf_addr); >> > > >Double pointer does not represent 2D arrays. Please refer to >https://stackoverflow.com/questions/4470950/why-cant-we-use-double-pointer-to-represent-two-dimensional-arrays >
Yes, I agree, but I don't think it is the case here. >It will cause segment fault in enqueue/dequeue. Hmm, have you debug it? Which line caused the segfault? You can refer to test_rawdev_enqdeq function in skeleton_rawdev_test.c, what it does is similar to my suggestion, and you just need one alloc/free. Thanks, Xiaolong > >I will free twice. > >> > >2.17.1 >> > >