M
mm
Hi All,
I have a deque which holds pointers to type user defined struct uwb_t.
//The deque and the pointer to struct is declared as follows
#include <deque.h>
void process1()
{
deque <struct uwb_t*> uwb_header_q;
struct uwb_t* header_uwb;
.......
//process1 goes on to assign the pointers and pushes them onto the deque:
header_uwb = new (struct uwb_t);
uwb_header_q.push_back(header_uwb); // Push the pointer onto the deque
}
// Another process deals with the header at the front of the queue.
// Once processing is complete, I want to delete the ptr and free the
sizeof(uwb_t) memory that was allocated via the new operator
// Is this the correct way to do it?
void process2()
{
............ // process head of queue
delete uwb_header_q[0]; // Free the memory occupied by the
object pointed to by the head of the deque
uwb_header_q.pop_front(); // Remove the pointer from the head of the
deque
}
Thanks!
-Martin (apologies for duplicate on c++.moderated)
I have a deque which holds pointers to type user defined struct uwb_t.
//The deque and the pointer to struct is declared as follows
#include <deque.h>
void process1()
{
deque <struct uwb_t*> uwb_header_q;
struct uwb_t* header_uwb;
.......
//process1 goes on to assign the pointers and pushes them onto the deque:
header_uwb = new (struct uwb_t);
uwb_header_q.push_back(header_uwb); // Push the pointer onto the deque
}
// Another process deals with the header at the front of the queue.
// Once processing is complete, I want to delete the ptr and free the
sizeof(uwb_t) memory that was allocated via the new operator
// Is this the correct way to do it?
void process2()
{
............ // process head of queue
delete uwb_header_q[0]; // Free the memory occupied by the
object pointed to by the head of the deque
uwb_header_q.pop_front(); // Remove the pointer from the head of the
deque
}
Thanks!
-Martin (apologies for duplicate on c++.moderated)