Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8861693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:32:53+00:00 2026-06-14T15:32:53+00:00

I’ve got an library which must read data from sqlite database by calling extern

  • 0

I’ve got an library which must read data from sqlite database by calling

extern int read(char** argv, int argc); // from header

it must process:

int read(char** argv, int argc) {
    char* lineborder1;
    char* lineborder2;
    char* spaces1;
    char* spaces2;
    int maxl2 = 0, maxl1 = 0;
    int i, maxi1, maxi2;
    if (prelude() == -1) return -1;
    // etc...

where prelude is inner procedure for sqlite connection:

int prelude() {
    timefile = 0;
    f = NULL;
#ifndef WIN32
    char* temp = (char*)calloc(200, sizeof(char));
#endif
    queries = (char**)malloc(sizeof(char*) * q_cnt);
    for (x = 0; x < q_cnt; x++) {
        queries[x] = (char*)malloc(sizeof(char) * q_size);
        }
#ifdef WIN32
    retval = sqlite3_open("todo.db3", &handle);
#else
    home = (char*)getenv("HOME");
    strcpy(temp, home);
    retval = sqlite3_open(strcat(temp, "/.todo.db3"), &handle);
    free(temp);
#endif
    if (retval) {
        printf("Database connection failed\n\r");
        return -1;
        }
    return 0;
    }

whole source is here : bitbucket: ctodo.c

I call this read from my application:

else if ((strcmp(argv[1], "read") == 0) || (strcmp(argv[1], "r") == 0)) {
    return read(argv, argc);

but getting infinity cycle of this read call:

>>./todo r
Database connection failed
Database connection failed
Database connection failed
.... etc

here is how do I build it:

gcc -I . -c -o todo.a ctodo.c -lsqlite3 -O3
gcc -I . -o todo cctodo.c -lsqlite3 -O3 todo.a

help or version calls wrok fine and read works fine on windows, something specific to my linux build is here but I can’t find a bug so far. what could call this read to run in infinity cycle like that?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T15:32:54+00:00Added an answer on June 14, 2026 at 3:32 pm

    The read function is defined in libc.so, and used to, you know, read data.

    It is exceedingly likely that sqlite3_open() calls it.

    By introducing your own function called read(), you’ve made your program enter infinite loop. If you wait long enough, your program will run out of stack and crash.

    Doctor, it hurts when I do that. Well, don’t do that 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a text area in my form which accepts all possible characters from
I have a view passing on information from a database: def serve_article(request, id): served_article
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I've got a string that has curly quotes in it. I'd like to replace
I would like to run a str_replace or preg_replace which looks for certain words

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.