baidu
摘要: 服务器代码依赖了boost的function和bind,用来做回调,异步调用时会出现这种down机.闲话少说上代码:void fn(std::string str);char *temp_str = new char[24];strcpy(temp_str,"1212");boost::function f = boost::bind(fn,temp_str);f();这边的f函数对象里面保存了一个temp_str的指针,如果是同步调用,会有临时的std::string变量产生,产生拷贝一次temp_str,之后就不在引用temp_str,所以不会出现任何问题;可是如果是异 阅读全文
posted @ 2012-04-15 16:59 egmkang 阅读(1472) 评论(4) 推荐(0) 编辑