this post was submitted on 01 Sep 2025
462 points (98.9% liked)

Programmer Humor

26152 readers
1033 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
 

"What's your go-to tool as a programmer these days?"

My brain, same as it always has been!

🤭This guy is a gold mine

you are viewing a single comment's thread
view the rest of the comments
[–] Dumhuvud@programming.dev 1 points 3 days ago* (last edited 3 days ago)

I misremembered the whole thing. It was still related to cleaning up after a failure, but there was only one resource I had to deal with. That's how it looks like:

    sqlite3 *db;
    int r;

    r = sqlite3_open("./data.db", &db);
    if (r) {
        std::cerr << "Can't open the database: " << sqlite3_errmsg(db) << std::endl;
        return r;
    }

    r = sqlite3_exec(db, "CREATE TABLE IF NOT EXISTS foo(...);", nullptr, nullptr, nullptr);
    if (r != SQLITE_OK) {
        std::cerr << "Can't create a table called foo: " << sqlite3_errmsg(db) << std::endl;
        goto out;
    }

    // a few more sqlite3_exec calls;
    // some sqlite3_prepare_v2 calls combined with sqlite3_bind_* and sqlite3_step calls
    // for repeated queries.

out:
    sqlite3_close(db);
    return r;