Module Name:    src
Committed By:   roy
Date:           Mon Oct  3 19:18:55 UTC 2011

Modified Files:
        src/lib/libterminfo: curterm.c setupterm.c term.c term_private.h

Log Message:
Remove _ti_freeterm as consumers should just use del_curterm.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/lib/libterminfo/curterm.c
cvs rdiff -u -r1.2 -r1.3 src/lib/libterminfo/setupterm.c
cvs rdiff -u -r1.12 -r1.13 src/lib/libterminfo/term.c
cvs rdiff -u -r1.8 -r1.9 src/lib/libterminfo/term_private.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libterminfo/curterm.c
diff -u src/lib/libterminfo/curterm.c:1.5 src/lib/libterminfo/curterm.c:1.6
--- src/lib/libterminfo/curterm.c:1.5	Sun Oct  2 19:24:25 2011
+++ src/lib/libterminfo/curterm.c	Mon Oct  3 19:18:55 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: curterm.c,v 1.5 2011/10/02 19:24:25 roy Exp $ */
+/* $NetBSD: curterm.c,v 1.6 2011/10/03 19:18:55 roy Exp $ */
 
 /*
  * Copyright (c) 2009, 2011 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: curterm.c,v 1.5 2011/10/02 19:24:25 roy Exp $");
+__RCSID("$NetBSD: curterm.c,v 1.6 2011/10/03 19:18:55 roy Exp $");
 
 #include <assert.h>
 #include <stdlib.h>
@@ -90,9 +90,15 @@ int
 del_curterm(TERMINAL *oterm)
 {
 
-	_DIAGASSERT(oterm != NULL);
-	_ti_freeterm(oterm);
-	return 0;
+	if (oterm == NULL)
+		return ERR;
+	free(oterm->_area);
+	free(oterm->strs);
+	free(oterm->nums);
+	free(oterm->flags);
+	free(oterm->_userdefs);
+	free(oterm);
+	return OK;
 }
 
 char *

Index: src/lib/libterminfo/setupterm.c
diff -u src/lib/libterminfo/setupterm.c:1.2 src/lib/libterminfo/setupterm.c:1.3
--- src/lib/libterminfo/setupterm.c:1.2	Thu Feb 11 00:27:09 2010
+++ src/lib/libterminfo/setupterm.c	Mon Oct  3 19:18:55 2011
@@ -1,7 +1,7 @@
-/* $NetBSD: setupterm.c,v 1.2 2010/02/11 00:27:09 roy Exp $ */
+/* $NetBSD: setupterm.c,v 1.3 2011/10/03 19:18:55 roy Exp $ */
 
 /*
- * Copyright (c) 2009 The NetBSD Foundation, Inc.
+ * Copyright (c) 2009, 2011 The NetBSD Foundation, Inc.
  *
  * This code is derived from software contributed to The NetBSD Foundation
  * by Roy Marples.
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: setupterm.c,v 1.2 2010/02/11 00:27:09 roy Exp $");
+__RCSID("$NetBSD: setupterm.c,v 1.3 2011/10/03 19:18:55 roy Exp $");
 
 #include <assert.h>
 #include <err.h>
@@ -82,7 +82,7 @@ ti_setupterm(TERMINAL **nterm, const cha
 
 	error = _ti_getterm(*nterm, term, 0);
 	if (error != 1) {
-		free(*nterm);
+		del_curterm(*nterm);
 		*nterm = NULL;
 		switch (error) {
 		case -1:

Index: src/lib/libterminfo/term.c
diff -u src/lib/libterminfo/term.c:1.12 src/lib/libterminfo/term.c:1.13
--- src/lib/libterminfo/term.c:1.12	Mon Apr 11 21:37:19 2011
+++ src/lib/libterminfo/term.c	Mon Oct  3 19:18:55 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: term.c,v 1.12 2011/04/11 21:37:19 roy Exp $ */
+/* $NetBSD: term.c,v 1.13 2011/10/03 19:18:55 roy Exp $ */
 
 /*
  * Copyright (c) 2009, 2010, 2011 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: term.c,v 1.12 2011/04/11 21:37:19 roy Exp $");
+__RCSID("$NetBSD: term.c,v 1.13 2011/10/03 19:18:55 roy Exp $");
 
 #include <sys/stat.h>
 
@@ -70,18 +70,18 @@ _ti_readterm(TERMINAL *term, const char 
 
 	term->flags = calloc(TIFLAGMAX + 1, sizeof(char));
 	if (term->flags == NULL)
-		goto err;
+		return -1;
 	term->nums = malloc((TINUMMAX + 1) * sizeof(short));
 	if (term->nums == NULL)
-		goto err;
+		return -1;
 	memset(term->nums, (short)-1, (TINUMMAX + 1) * sizeof(short));
 	term->strs = calloc(TISTRMAX + 1, sizeof(char *));
 	if (term->strs == NULL)
-		goto err;
+		return -1;
 	term->_arealen = caplen;
 	term->_area = malloc(term->_arealen);
 	if (term->_area == NULL)
-		goto err;
+		return -1;
 	memcpy(term->_area, cap, term->_arealen);
 
 	cap = term->_area;
@@ -205,15 +205,11 @@ _ti_readterm(TERMINAL *term, const char 
 				break;
 			default:
 				errno = EINVAL;
-				goto err;
+				return -1;
 			}
 		}
 	}
 	return 1;
-	
-err:
-	_ti_freeterm(term);
-	return -1;
 }
 
 static int
@@ -404,16 +400,3 @@ _ti_getterm(TERMINAL *term, const char *
 
 	return r;
 }
-	
-void
-_ti_freeterm(TERMINAL *term)
-{
-
-	if (term != NULL) {
-		free(term->_area);
-		free(term->strs);
-		free(term->nums);
-		free(term->flags);
-		free(term->_userdefs);
-	}
-}

Index: src/lib/libterminfo/term_private.h
diff -u src/lib/libterminfo/term_private.h:1.8 src/lib/libterminfo/term_private.h:1.9
--- src/lib/libterminfo/term_private.h:1.8	Wed Sep 22 06:10:51 2010
+++ src/lib/libterminfo/term_private.h	Mon Oct  3 19:18:55 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: term_private.h,v 1.8 2010/09/22 06:10:51 roy Exp $ */
+/* $NetBSD: term_private.h,v 1.9 2011/10/03 19:18:55 roy Exp $ */
 
 /*
  * Copyright (c) 2009, 2010 The NetBSD Foundation, Inc.
@@ -114,7 +114,6 @@ const char *	_ti_numid(ssize_t);
 const char *	_ti_strid(ssize_t);
 int		_ti_getterm(TERMINAL *, const char *, int);
 void		_ti_setospeed(TERMINAL *);
-void		_ti_freeterm(TERMINAL *);
 
 /* libterminfo can compile terminfo strings too */
 #define TIC_WARNING	(1 << 0)

Reply via email to