小编wes*_*bin的帖子

C++:抛出'std :: bad_alloc'实例后调用terminate

我正在实现一个双重链接列表类,它存储"桶"(节点),每个包含预定义数量的字符.每个存储桶存储指向下一个和前一个存储桶的指针,列表类(BucketString)存储指向头部存储桶的指针.我正在编译使用g ++抛出错误

terminate called after throwing an instance of 'std::bad_alloc'
  what(): std::bad_alloc
make: *** [run] Aborted (core dumped)
Run Code Online (Sandbox Code Playgroud)

每当我运行代码并将一串字符添加到列表中时,使用以下add方法(包含在我的bucket类中),并在需要时从列表类自己的方法中调用.

码:

std::size_t bucketSizeB;
int filled;
char* str;
Bucket* next;
Bucket* prev;

Bucket::Bucket() : bucketSizeB(7), str(new char[7]), next(NULL), prev(NULL), filled(0)
{}

Bucket::Bucket(std::size_t bucketSizeB_) : bucketSizeB(bucketSizeB_), str(new char[bucketSizeB]), next(NULL), prev (NULL), filled(0)
{}

Bucket::Bucket(const Bucket& rhs) : bucketSizeB(rhs.bucketSizeB), next(rhs.next), prev(rhs.prev), filled(rhs.filled)
{
    for (int i = 0 ; i < (int) bucketSizeB ; i++)
    {
        str[i] = rhs.str[i];
    }
}

void Bucket::add(std::string line) …
Run Code Online (Sandbox Code Playgroud)

c++ runtime-error

8
推荐指数
2
解决办法
5万
查看次数

使用 wget 从私有 github 仓库下载目录

有没有办法使用wget (或 curl 或其他一些 linux 终端命令)来做到这一点?Git 未安装在将运行此命令的机器上。

目前,当我尝试通过运行以下命令下载我的 repo 的 lib 文件夹时,出现 404 Not Found 错误:

wget --header="Authorization: token {token}" -r https://raw.githubusercontent.com/{user}/{repo}/{branch}/{path to builds dir}/lib
Run Code Online (Sandbox Code Playgroud)

该目录肯定存在,下面的代码从目录中下载一个文件就好了:

wget --header="Authorization: token {token}" --output-document={file}.jar https://raw.githubusercontent.com/{user}/{repo}/{branch}/{path to builds dir}/lib/{file}.jar
Run Code Online (Sandbox Code Playgroud)

git curl wget

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

标签 统计

c++ ×1

curl ×1

git ×1

runtime-error ×1

wget ×1