[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[Libevent-users] evbuffer result string sometimes not right when use func evbuffer_add_reference()
- To: libevent-users@xxxxxxxx
- Subject: [Libevent-users] evbuffer result string sometimes not right when use func evbuffer_add_reference()
- From: æåå <bit.kevin@xxxxxxxxx>
- Date: Thu, 12 Apr 2012 17:33:50 +0800
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: libevent-users-outgoing@xxxxxxxx
- Delivered-to: libevent-users@xxxxxxxx
- Delivery-date: Thu, 12 Apr 2012 05:34:05 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=lVpf1aAo0zRZIz7CqA3YDbWPPQJVSluK0knrw4P7aKM=; b=eVl1PXtaAa+hJ16G6H5fr2TKvMV3FkFV0gaofq6S6LX7EXVPAypXf4ZfypEycFrDU2 8m7GvTGJg5x07+qarS3dhc7qs6mNeJtgYUzXv4ilIkdCkKYIWMHZ4LLRpaEXXGoRDkT2 w1nAAGa7N/tOwPbEj03T+xB9pZkExHJEDj3E/dWFRJcnujMfrmD6vTggzjO/RGG+J8Lj vlTS22bKYOx4v6juzFPHOCqY4/sia9xTTbLoX4fkAPoXsW9wOk69xwxBc2/+GHerJBmd /UUR9cCV+sN3AmWvLYoARlqGzISq2lBJRnhnZgcqP1SG5HGAmOV6LJ4kKsex0zeZUdgM t1eQ==
- Reply-to: libevent-users@xxxxxxxxxxxxx
- Sender: owner-libevent-users@xxxxxxxxxxxxx
LSB Version: :core-3.1-amd64:core-3.1-ia32:core-3.1-noarch:graphics-3.1-amd64:graphics-3.1-ia32:graphics-3.1-noarch
Distributor ID: CentOS
Description: CentOS release 5.4 (Final)
Release: 5.4
Codename: Final
ldd <my exe>:
libevent-2.0.so.5 => /usr/local/lib/libevent-2.0.so.5 (0x00002b8af3973000)
libevent_pthreads-2.0.so.5 =>
/usr/local/lib/libevent_pthreads-2.0.so.5 (0x00002b8af3bb6000)
libevent_openssl-2.0.so.5 => /usr/local/lib/libevent_openssl-2.0.so.5
(0x00002b8af3db8000)
use func evbuffer_add_reference(), code tips:
evbuffer_add_printf(buf_, "\"detail\":\"");
evbuffer_add_reference(buf_, dp->detail, strlen(dp->detail),
NULL, NULL);
evbuffer_add_printf(buf_, "\"");
sometimes result is wrong, especially when the string's length is long.
result string (wrong):
"detail":""\u3000\u3000\u672c\u4e66\u662f\u6539\u9769\u5b97\u652f\u67f1\u6027\u4eba\u7269\u5df4\u6587\u514b\u7684\u6d69\u701a\u5de8\u8457\u300a\u6539\u9769\u5b97\u6559\u4e49\u795e\u5b66\u300b\u7f29\u5199\u672c\u3002\u8fd9\u53ef\u4ee5\u770b\u4f5c\u662f\u4e00\u672c\u57fa\u7763\u6559\u4fe1\u4ef0\u5728\u6559\u4e49\u771f\u7406\u65b9\u9762\u7684\u6559\u79d1\u4e66\u3002\u5173\u4e8e\u57fa\u7763\u6559\u4fe1\u4ef0\u7684\u6838\u5fc3\u771f\u7406\u6559\u5bfc\uff0c\u90fd\u53ef\u4ee5\u5728\u8fd9\u91cc\u627e\u5230\u4ee5\u5723\u7ecf\u4e3a\u672c\uff0c\u7cfb\u7edf\u3001\u6574\u5168\u53c8\u7b80\u7ec3\u7684\u9610\u8ff0\u3002\u4f46\u5b83\u53c8\u4e0d\u53ea\u662f\u4e00\u822c\u610f\u4e49\u4e0a\u7684\u6559\u79d1\u4e66\uff0c\u751a\u81f3\u4e0d\u662f\u4e00\u822c\u610f\u4e49\u4e0a\u5173\u4e8e\u57fa\u7763\u6559\u6559\u4e49\u771f\u7406\u7684\u6559\u79d1\u4e66\uff0c\u56e0\u4e3a\u5b83\u5e76\u4e0d\u53ea\u662f\u7b80\u5355\u7f57\u5217\u4e00\u4e9b\u5173\u4e8e\u57fa\u7763\u6559\u6559\u4e49\u771f\u7406\u7684\u547d\u9898\u3002\u201c\u771f\u7406\u201d\u5bf9\u5b9e\u81f3\u540d\u5f52\u7684\u57fa\u7763\u6559\u4fe1\u4ef0\u6765\u8bf4\uff0c\u610f\u5473\u7740\u201c\u751f\u547d\u201d\u3002\u8fd9\u672c\u4e66\u5c31\u662f\u5bf9\u8fd9\u53e5\u8bdd\u7684\u4e00\u4e2a\u7cbe\u5f69\u9610\u91ca\u3002\n\u3000\u3000\u6e29\u548c\u7684\u5df4\u6587\u514b\u4ee5\u4e00\u79cd\u5b66\u672f\u5927\u5bb6\u7684\u98ce\u8303\uff0c\u65e2\u80fd\u5728\u5404\u79cd\u770b\u6cd5\u4e2d\u53d1\u73b0\u5173\u4e8e\u4e0a\u5e1d\u7684\u771f\u7406\uff0c\u540c\u65f6\u53c8\u57fa\u4e8e\u5723\u7ecf\u548c\u4fe1\u4ef0\u7684\u7acb\u573a\u5bf9\u4e0d\u5408\u7406\u7684\u6210\u5206\u52a0\u4ee5\u62d2\u65a5\u3002\u672c\u4e66\u4e2d\u91c7\u53d6\u7684\u662f\u6539\u9769\u5b97\u4f20\u7edf\u7684\u67b6\u6784\uff0c\u4f46\u6240\u5448\u73b0\u7684\u53c8\u7edd\u4e0d\u662f\u67d0\u79cd\u72ed\u9698\u7684\u5b97\u6d3e\u4e3b\u4e49\u795e\u5b66\uff0c\u800c\u662f\u771f\u6b63\u5927\u516c\u6559\u4f1a\u795e\u5b66\u7684\u7cbe\u9ad3\u3002\u662f\u4ed6\u6df1\u539a\u5b66\u672f\u4fee\u517b\u7684\u4f53\u73b0\uff0c\u66f4\u662f\u4ed6\u57fa\u4e8e\u4fe1\u4ef0\u7684\u6df1\u523b\u8868\u8fbe\u3002
result string (right):
"detail":" \u300a\u5723\u7ecf\u300b\u4e2d\u4ece\u795e\u7684\u521b\u9020\u5230\u57fa\u7763\u5728\u5730\u4e0a\u7684\u751f\u6d3b\uff0c\u56f0\u60d1\u7740\u8bf8\u591a\u601d\u60f3\u5bb6\u3001\u54f2\u5b66\u5bb6\u3001\u79d1\u5b66\u5bb6\u548c\u6000\u7591\u8bba\u8005\u3002 \u300a\u65b0\u94c1\u8bc1\u5f85\u5224\u300b\u7684\u8457\u4f5c\u8005\u9ea6\u9053\u536b\u5728\u672c\u4e66\u4e2d\u9488\u5bf9\u4eba\u4eec\u5e38\u95ee\u7684\u95ee\u9898\u8fdb\u884c\u56de\u7b54\uff0c\u4f8b\u5982\uff1a\u8036\u7a23\u7684\u795e\u6027\uff0c\u795e\u5b58\u5728\u7684\u771f\u5b9e\u6027\uff0c\u521b\u9020\u8bba\u7684\u8bc1\u636e\u7b49\u3002"
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users in the body.