From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Emanuele Giaquinta Newsgroups: gmane.emacs.devel Subject: Re: [Emacs-diffs] emacs/src term.c Date: Mon, 8 Dec 2008 19:23:37 +0100 Message-ID: <20081208182337.GC4177@orion.lan> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="gKMricLos+KVdGMg" X-Trace: ger.gmane.org 1228762482 6388 80.91.229.12 (8 Dec 2008 18:54:42 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 8 Dec 2008 18:54:42 +0000 (UTC) Cc: emacs-devel@gnu.org To: Chong Yidong Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Dec 08 19:55:45 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1L9lGY-0005Je-Bt for ged-emacs-devel@m.gmane.org; Mon, 08 Dec 2008 19:55:35 +0100 Original-Received: from localhost ([127.0.0.1]:48506 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L9lFN-0008HU-GZ for ged-emacs-devel@m.gmane.org; Mon, 08 Dec 2008 13:54:21 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1L9klx-0004gB-59 for emacs-devel@gnu.org; Mon, 08 Dec 2008 13:23:57 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1L9klt-0004eS-A5 for emacs-devel@gnu.org; Mon, 08 Dec 2008 13:23:56 -0500 Original-Received: from [199.232.76.173] (port=53086 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1L9klt-0004eK-3u for emacs-devel@gnu.org; Mon, 08 Dec 2008 13:23:53 -0500 Original-Received: from nf-out-0910.google.com ([64.233.182.189]:6830) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1L9klr-0004tL-Tm for emacs-devel@gnu.org; Mon, 08 Dec 2008 13:23:52 -0500 Original-Received: by nf-out-0910.google.com with SMTP id c7so737264nfi.26 for ; Mon, 08 Dec 2008 10:23:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:references:mime-version:content-type:content-disposition :in-reply-to; bh=mcS5M9zTez20SC7tFtlEd2i6Q/UylVlp25ITwGR8QmU=; b=rdMmK8Qt3omxj6zN0Dtn0YW9WZLh+2xbNRvWbHHe3mCA13GxEuo/x4bQ8LmcI31LK5 BymXJlwx8ZdzxueEd4Wkv5xQa5IpVaxl/GMH2JaZ16qmN52kV+XJPYRZU49vqeCgwQrM 1KZ3n8q0PoE6Nc8V5sJURseWpHWfoIRV3d2rs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to; b=erGGjiFtSnZ/DFnFmilNIDQ+l4ZlUiCPsdfLH0ZwjYUi3zouDnm1tvynPXw/mJJK7y rmNQrKQZiovg/9aPzkEpXrUbQfsJnP6yTtAPJiZtaVz9OMqRNAKn5CTWYPk6JELZ6dZa 3odjNigckMQItpXUOXV9LcvppFTR4yFmJ1Nyw= Original-Received: by 10.86.84.18 with SMTP id h18mr2802508fgb.69.1228760622278; Mon, 08 Dec 2008 10:23:42 -0800 (PST) Original-Received: from localhost (host135-107-dynamic.16-87-r.retail.telecomitalia.it [87.16.107.135]) by mx.google.com with ESMTPS id 4sm11837018fgg.52.2008.12.08.10.23.39 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 08 Dec 2008 10:23:41 -0800 (PST) Content-Disposition: inline In-Reply-To: X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:106685 Archived-At: --gKMricLos+KVdGMg Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Dec 08, 2008 at 02:44:31PM +0000, Chong Yidong wrote: > Index: term.c > =================================================================== > RCS file: /sources/emacs/emacs/src/term.c,v > retrieving revision 1.229 > retrieving revision 1.230 > diff -u -b -r1.229 -r1.230 > --- term.c 27 Sep 2008 10:50:48 -0000 1.229 > +++ term.c 8 Dec 2008 14:44:30 -0000 1.230 > @@ -581,10 +581,10 @@ > required = MAX_MULTIBYTE_LENGTH * src_len; > if (encode_terminal_src_size < required) > { > - if (encode_terminal_src_size == 0) > - encode_terminal_src = xmalloc (required); > - else > + if (encode_terminal_src) > encode_terminal_src = xrealloc (encode_terminal_src, required); > + else > + encode_terminal_src = xmalloc (required); > encode_terminal_src_size = required; > } > > @@ -740,6 +740,10 @@ > if (encode_terminal_dst_size == 0) > { > encode_terminal_dst_size = encode_terminal_src_size; > + if (encode_terminal_dst) > + encode_terminal_dst = xrealloc (encode_terminal_dst, > + encode_terminal_dst_size); > + else > encode_terminal_dst = xmalloc (encode_terminal_dst_size); > } > coding->destination = encode_terminal_dst; Any reason to not simply use realloc? (realloc(NULL, size) == malloc(size)) A patch is attached in case it is ok. Emanuele --gKMricLos+KVdGMg Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="realloc.diff" diff --git a/src/term.c b/src/term.c index 32bc4f6..dc0cb38 100644 --- a/src/term.c +++ b/src/term.c @@ -581,10 +581,7 @@ encode_terminal_code (src, src_len, coding) required = MAX_MULTIBYTE_LENGTH * src_len; if (encode_terminal_src_size < required) { - if (encode_terminal_src) encode_terminal_src = xrealloc (encode_terminal_src, required); - else - encode_terminal_src = xmalloc (required); encode_terminal_src_size = required; } @@ -740,11 +737,8 @@ encode_terminal_code (src, src_len, coding) if (encode_terminal_dst_size == 0) { encode_terminal_dst_size = encode_terminal_src_size; - if (encode_terminal_dst) encode_terminal_dst = xrealloc (encode_terminal_dst, encode_terminal_dst_size); - else - encode_terminal_dst = xmalloc (encode_terminal_dst_size); } coding->destination = encode_terminal_dst; coding->dst_bytes = encode_terminal_dst_size; @@ -1218,15 +1212,10 @@ calculate_costs (struct frame *frame) max_frame_lines = max (max_frame_lines, FRAME_LINES (frame)); max_frame_cols = max (max_frame_cols, FRAME_COLS (frame)); - if (char_ins_del_vector != 0) char_ins_del_vector = (int *) xrealloc (char_ins_del_vector, (sizeof (int) + 2 * max_frame_cols * sizeof (int))); - else - char_ins_del_vector - = (int *) xmalloc (sizeof (int) - + 2 * max_frame_cols * sizeof (int)); bzero (char_ins_del_vector, (sizeof (int) + 2 * max_frame_cols * sizeof (int))); --gKMricLos+KVdGMg--