munmap_chunk():在向量上执行push_back时指针无效

时间:2012-12-07 04:07:49

标签: c++ networking pointers

void build_queues() {
    for (int i = 1; i < configVector.size(); i++) {
        //ROUTER -> ROUTER
        if (configVector[i][0] == "3") {
            if (atoi(configVector[i][1].c_str()) == ROUTER_ID) {
                int connectedId = atoi(configVector[i][3].c_str());
                Queue tmp;
                tmp.initialize(get_ip_for_id(connectedId), QUEUE_LENGTH, connectedId);
                NUM_INTERFACES++;
                interfaces.push_back(tmp);
            } else if (atoi(configVector[i][3].c_str()) == ROUTER_ID) {
                int connectedId = atoi(configVector[i][1].c_str());
                Queue tmp;
                tmp.initialize(get_ip_for_id(connectedId), QUEUE_LENGTH, connectedId);
                NUM_INTERFACES++;
                interfaces.push_back(tmp);
            }
        }
        //ROUTER -> END HOST
        else if (configVector[i][0] == "4") {
            if (atoi(configVector[i][1].c_str()) == ROUTER_ID) {
                int connectedId = atoi(configVector[i][4].c_str());
                Queue tmp;
                tmp.initialize(get_ip_for_id(connectedId), QUEUE_LENGTH, connectedId);
                NUM_INTERFACES++;
                interfaces.push_back(tmp);
            }
        }
    }
}

接口是矢量&lt;队列&gt;。每当我push_back多个队列时,它会给我无效的指针错误。有谁可以指出错误?

0 个答案:

没有答案