From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Leo Newsgroups: gmane.emacs.devel Subject: Re: Move sha1 to C? Date: Tue, 24 May 2011 01:38:35 +0800 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1306172335 23378 80.91.229.12 (23 May 2011 17:38:55 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 23 May 2011 17:38:55 +0000 (UTC) Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon May 23 19:38:51 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QOZ5c-0002xM-Rn for ged-emacs-devel@m.gmane.org; Mon, 23 May 2011 19:38:48 +0200 Original-Received: from localhost ([::1]:55577 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QOZ5c-0004ZS-3a for ged-emacs-devel@m.gmane.org; Mon, 23 May 2011 13:38:48 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:59211) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QOZ5Z-0004ZA-Ek for emacs-devel@gnu.org; Mon, 23 May 2011 13:38:46 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QOZ5X-0002Kv-Ko for emacs-devel@gnu.org; Mon, 23 May 2011 13:38:45 -0400 Original-Received: from mail-pw0-f41.google.com ([209.85.160.41]:47519) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QOZ5X-0002Kh-Dt; Mon, 23 May 2011 13:38:43 -0400 Original-Received: by pwi12 with SMTP id 12so3687096pwi.0 for ; Mon, 23 May 2011 10:38:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-type; bh=ShMX9ot2VWsy0/uw0sQ1LcWfQOYunztvQ+UbWt7A5Ms=; b=D23RJgVOt0/dj5jrtDYmVDeAWin0Bv6PUqxWFxKMpWiZ8MsSOwZghu0/Gn0Xbf18cP rsGG4p4IVnzsnX9nLqmECdpOFO/R+PlHTfV6kKKE1GSYehVxty6HBXII5kFKN4M0hfwN 3u8PuxzWRQN5sJ+PRJEQ7CWX6DQ41Pt5/Cxk4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; b=inoE/myaTOzFWPngrxQE+HttODASR2sSHFlfBuysETIwcuSlC3C+H/mn18LSO4SW7O /t7b3VJMVw6dfBob8YpzJIHNf/YDaZFA46flvEGjW9brWxxuDABvxiR2Lu2RViSNRNrJ 3JAq3/FwJY3bVZr0El4J6Y2XuV0FxNhFNh75w= Original-Received: by 10.68.63.2 with SMTP id c2mr2416469pbs.54.1306172322281; Mon, 23 May 2011 10:38:42 -0700 (PDT) Original-Received: from th041094.ip.tsinghua.edu.cn (th041067.ip.tsinghua.edu.cn [59.66.41.67]) by mx.google.com with ESMTPS id n3sm1583511pbh.16.2011.05.23.10.38.39 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 23 May 2011 10:38:41 -0700 (PDT) In-Reply-To: (Eli Zaretskii's message of "Mon, 23 May 2011 03:21:19 -0400") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3.50 (Mac OS X 10.6.7) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.160.41 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:139655 Archived-At: On 2011-05-23 15:21 +0800, Eli Zaretskii wrote: > Note that gnulib's sha1.c uses malloc, which is not safe in Emacs. > So either make sure sha1_stream is never ever called by Emacs, or use > xmalloc instead. For the record, it seems there is no need to use sha1_stream: (defun sha1-file (file) (with-temp-buffer (set-buffer-multibyte nil) (insert-file-contents file) (sha1 (current-buffer)))) (benchmark-run 1 (sha1-file "Path-to-a-700M-file")) (9.66299 1 0.11788399999999999) (benchmark-run 1 (shell-command-to-string "shasum Path-to-a-700M-file")) (5.64725 0 0.0) Leo