From patchwork Wed Apr 2 09:18:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Frysinger X-Patchwork-Id: 386 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx20.g.dreamhost.com (mx2.sub5.homie.mail.dreamhost.com [208.113.200.128]) by wilcox.dreamhost.com (Postfix) with ESMTP id 14E57360091 for ; Wed, 2 Apr 2014 02:18:41 -0700 (PDT) Received: by homiemail-mx20.g.dreamhost.com (Postfix, from userid 14307373) id 8063340C42A6B; Wed, 2 Apr 2014 02:18:41 -0700 (PDT) X-Original-To: glibc@patchwork.siddhesh.in Delivered-To: x14307373@homiemail-mx20.g.dreamhost.com Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by homiemail-mx20.g.dreamhost.com (Postfix) with ESMTPS id 5C97340ADAF62 for ; Wed, 2 Apr 2014 02:18:41 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id; q=dns; s= default; b=b8CJmoCdzrADWboH4z4oZ3LuiX3fWpG4L09zhVJLO+QA0cRZKzzM9 A3TJaiWXTVh/g8CJRxYyv2UvwQY9+mwQDEIc2m6InhA4UZklqMiUL20E7nkX4Oot WAkn24LJxP1SWtkZZjYAOrdY9tRpKhuGCdDjRmyhM1gqzBdARYhx9Y= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id; s=default; bh=+pNDe6eeomAIi1Yx+N7Nga243dE=; b=FeSZt1OVcBSMpAP6nl0QdXAwURny lCSAlLhb4G0RS//4SUheiUD5oqIHup6o2H/Y4s7fYEgt4g08jhs1mS1zQTwEMP3y vfvlTJ/aWAYHK6nrzOFoB7sORWoBx8Ijodu83gbDhTT7lITxekA/001K5CNxn8E7 awGNOQPJ3qs9z+U= Received: (qmail 25613 invoked by alias); 2 Apr 2014 09:18:38 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 25601 invoked by uid 89); 2 Apr 2014 09:18:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.3 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: smtp.gentoo.org From: Mike Frysinger To: libc-alpha@sourceware.org Cc: David Svoboda Subject: [PATCH] manual: clarify buffer behavior in getline Date: Wed, 2 Apr 2014 05:18:31 -0400 Message-Id: <1396430311-1158-1-git-send-email-vapier@gentoo.org> X-DH-Original-To: glibc@patchwork.siddhesh.in From: David Svoboda If the user has requested automatic buffer creation, getline may create it and not free things when an error occurs. That means the user is always responsible for calling free() regardless of the return value. The current documentation does not explicitly cover this which leaves it slightly ambiguous to the reader. So clarify things. 2014-04-02 David Svoboda * manual/stdio.texi (Line-Oriented Input): Document buffer allocation explicitly. --- manual/stdio.texi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/manual/stdio.texi b/manual/stdio.texi index a4364f7..db55f05 100644 --- a/manual/stdio.texi +++ b/manual/stdio.texi @@ -1298,7 +1298,8 @@ back in @code{*@var{n}}. If you set @code{*@var{lineptr}} to a null pointer, and @code{*@var{n}} to zero, before the call, then @code{getline} allocates the initial -buffer for you by calling @code{malloc}. +buffer for you by calling @code{malloc}. This buffer remains allocated +even if @code{getline} encounters errors and is unable to read any bytes. In either case, when @code{getline} returns, @code{*@var{lineptr}} is a @code{char *} which points to the text of the line.