int total_cnt = 0;
int buf_size = big_data ? SEND_BIG_BUF_SIZE : SEND_BUF_SIZE;
- char databuf[buf_size];
+
+ // use malloc instead of general array definition to avoid seg fault in 'alloca' in MinGW env, only using big buf size.
+ char* databuf = (char*)g_malloc0( buf_size );
INFO( "send_n start. length:%d\n", length );
send_cnt = ( length - total_cnt );
}
- memset( &databuf, 0, send_cnt );
- memcpy( &databuf, (char*) ( data + total_cnt ), send_cnt );
+ memset( databuf, 0, send_cnt );
+ memcpy( databuf, (char*) ( data + total_cnt ), send_cnt );
send_cnt = send( client_sock, databuf, send_cnt, 0 );
}
+ g_free( databuf );
+
INFO( "send_n finished.\n" );
return total_cnt;