Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/63.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql ***“./text\u缓冲区中出错:已损坏的双链接列表:0x089cbd98**_Sql_C_Linux_Malloc_Freetds - Fatal编程技术网

Sql ***“./text\u缓冲区中出错:已损坏的双链接列表:0x089cbd98**

Sql ***“./text\u缓冲区中出错:已损坏的双链接列表:0x089cbd98**,sql,c,linux,malloc,freetds,Sql,C,Linux,Malloc,Freetds,我正在尝试使用FreeTDS制作应用程序。下面是我的代码 /* * Purpose: Test to see if row buffering and blobs works correctly. * Functions: dbbind dbnextrow dbopen dbresults dbsqlexec dbgetrow */ #include "common.h" #include "stdio.h" #include<stdlib.h> #include "rea

我正在尝试使用FreeTDS制作应用程序。下面是我的代码

/* 
 * Purpose: Test to see if row buffering and blobs works correctly.
 * Functions: dbbind dbnextrow dbopen dbresults dbsqlexec dbgetrow
 */

#include "common.h"
#include "stdio.h"
#include<stdlib.h>
#include "readline/readline.h"
#include "readline/history.h"
#include "string.h"

int
main(int argc, char **argv)
{

  char failed;
  int hasil;
  char ch;

  char* r = malloc(30);


  LOGINREC *login;
  DBPROCESS *dbproc;
  int i;
  int p = 0;
  char teststr[1024];
  DBINT testint;
    read_login_info(argc, argv);
    fprintf(stdout, "Starting %s\n", argv[0]);


/* Fortify_EnterScope(); */

      while(1)
      {
    char qrcode[50];
    char perintahsql[100] = "select * from REF_COBA where id=";
    char *alokasi="";

    while(ch != '\n')    // terminates if user hit enter
    {
      ch = getchar();
      qrcode[p] = ch;
      p++;
}
qrcode[p]='\0';
strcpy(r,qrcode);

alokasi = strsep(&r, ",");
strcpy(r,"");
p=0;
ch = "";
dbinit();
dberrhandle(syb_err_handler);
dbmsghandle(syb_msg_handler);
fprintf(stdout, "About to logon\n");
login = dblogin();
DBSETLPWD(login, PASSWORD);
DBSETLUSER(login, USER);
DBSETLAPP(login, "text_buffer");
//DBSETLHOST(login, "ntbox.dntis.ro");
DBSETLHOST(login, "192.168.1.9");

fprintf(stdout, "About to open\n");
dbproc = dbopen(login, SERVER);
if (strlen(DATABASE))
  dbuse(dbproc, DATABASE);
dbloginfree(login);

#ifdef MICROSOFT_DBLIB
  dbsetopt(dbproc, DBBUFFER, "100");
#else
  dbsetopt(dbproc, DBBUFFER, "100", 0);
#endif

dbcmd(dbproc, strcat(perintahsql,alokasi));
dbsqlexec(dbproc);

if (dbresults(dbproc) != SUCCEED)
{
  failed = 1;
  fprintf(stdout, "Was expecting a result set.");
  exit(1);
}
fprintf(stdout, "select\n");
for (i = 1; i <= dbnumcols(dbproc); i++)
  printf("col %d is %s\n", i, dbcolname(dbproc, i));
fprintf(stdout, "setelah for\n");
dbbind(dbproc, 1, INTBIND, 0, (BYTE *) & testint);
dbbind(dbproc, 2, CHARBIND, 0, (BYTE *) teststr);

for (i = 1; i < 2; i++)
{
  char expected[1024];
  sprintf(expected, "row %03d", i);
  if (i % 100 == 0) 
  {
dbclrbuf(dbproc, 100);
  }
  if (REG_ROW != dbnextrow(dbproc))
  {
failed = 1;
fprintf(stderr, "Failed.  Expected a row\n");
//exit(1);
  }
  else
  {
fprintf(stdout, "jalanin usb\n");
printf("Read a row of data -> %d %s\n", (int) testint, teststr);
hasil = system("/opt/usb1rc_linux USB1REL-172 R");
sleep(2);
hasil = system("/opt/usb1rc_linux USB1REL-172 r");
  }

}
dbfreebuf(dbproc);
dbexit();

  }
  return 0;
 }
我从FreeTDS修改了源代码,编译后有一些警告

bash-4.2生成文本缓冲区 CC text_buffer.o text_buffer.c:在函数“main”中: text_buffer.c:54:8:警告:赋值从指针生成整数而不进行强制转换[默认情况下启用] ch=; ^ text_buffer.c:18:7:警告:变量'hasil'已设置但未使用[-Wunused但已设置变量] 因特哈西尔; ^ text_buffer.c:17:8:警告:变量“失败”设置但未使用[-Wunused但设置变量] char失败; ^ CC common.o 文本缓冲区

我执行程序没有错误。该程序将检查用户的输入,然后运行sql命令。输入格式应为,例如123456,然后按enter键。输入50-60次后,会出现双链表错误。
有人能解释为什么会发生错误吗?

char*alokasi=;应为char*alokasi=NULL;和ch=;应该是ch='';亲爱的,当我输入50-60次时仍然会发生错误。