源文件如下,gcc编译的命令是gcc -g -Wall axel_demo.c axel.c conf.c conn.c ftp.c http.c tcp.c -lpthread -o new_axel
没有任何错误。
然后,运行./new_axel http://code.google.com/p/gnome-menu-fil ... menu-bar.c panel-menu bar.c
结果Segmentation fault。
代码: 全选
| 1#include <stdio.h>
| 2#include <string.h>
| 3#include "axel.h"
| 4
| 5int main( int argc, char *argv[] )
| 6{
| 7 /* example: a.out url filename */
| 8 conf_t *demo_conf_t_p;
| 9 axel_t *demo_axel_t_p = axel_new( demo_conf_t_p, 0, *( argv + 1 ) );
|10 if( demo_axel_t_p == NULL )
|11 printf( "WRONG: FAILED TO GET A NEW axel_t.\n" );
|12
|13 strcpy( demo_axel_t_p->filename, *( argv + 2 ) );
|14
|15 if( axel_open( demo_axel_t_p ) == 0 )
|16 printf( "WRONG: FAILED AT axel_open()." );
|17
|18 axel_start( demo_axel_t_p );
|19
|20 while( !( demo_axel_t_p->ready ) )
|21 {
|22 sleep( 2 );
|23 axel_do( demo_axel_t_p );
|24 }
|25
|26 axel_close( demo_axel_t_p );
|27
|28 return 0;
|29}