小编des*_*vel的帖子

Valgrind使用适当的free()和end()后,显示ncurses命令的内存泄漏

我有一个正在编写的程序可以更好地理解ncurses,当我将其推送通过时valgrind,它会输出与ncurses命令相关的许多泄漏。但是,我仅使用stdscrendwin()在末尾调用main()。我通过使用menu.h设置了用户选项,并在最后使用了free_item和free_menu:

menuChoice(WINDOW* scr, std::vector<std::string> *choices,
    std::string desc)
{
    //create the menu and the item pointer vector
    MENU* my_menu;
    std::vector<ITEM*> my_items;
    ITEM* cur = NULL;
    for (int x = 0; x < choices->size(); x++)
    {
        //populate the items vector with the string data in choices
        my_items.push_back(new_item(choices->at(x).c_str(), NULL));
    }
    //pushback a null item
    my_items.push_back((ITEM*)NULL);
    //create the menu and attach the items
    my_menu = new_menu((ITEM**)my_items.data());
    //print the desc and post the menu
    mvwprintw(scr, LINES - …
Run Code Online (Sandbox Code Playgroud)

c c++ curses memory-leaks ncurses

1
推荐指数
1
解决办法
2413
查看次数

标签 统计

c ×1

c++ ×1

curses ×1

memory-leaks ×1

ncurses ×1