Skip to content

Memory confusion #12

@KatharinaLin

Description

@KatharinaLin

I'm struggling to find that some problems on memory error, though I have solved it , but I can not understand why.Can you help me?
16 04 22 2147_1
why I add m_head->prev = NULL;It has no memory problem but it can not run.
Another one...

void DouList::operator=(const DouList &src) {
    this->clear();
    if (src.m_head != NULL) {
        DouListNode* m, *p, *r;
        m = src.m_head;
        while (m != NULL) {
            p = new DouListNode(m->elem, NULL, NULL);
            if (m == src.m_head) m_head = p;
            if (m != src.m_head) {
                r->next = p;
                p->prev = r;
            }
            r = p;
            p = p->next;
        }
        m_tail = r;
        p = r = m = NULL;
    }
}

I don't understand why this has no memory problem but can not run.(memory limit exceed 32MB for the two problems above.I'm sure only these two, because I passed after I fixed the the two.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions