[BusyBox-cvs] busybox/editors awk.c,1.2,1.3 sed.c,1.92,1.93 vi.c,1.24,1.25

Aaron Lehmann aaronl at busybox.net
Thu Nov 28 11:27:58 UTC 2002


Update of /var/cvs/busybox/editors
In directory winder:/tmp/cvs-serv23182/editors

Modified Files:
	awk.c sed.c vi.c 
Log Message:
Change if(x)free(x); to free(x);


Index: awk.c
===================================================================
RCS file: /var/cvs/busybox/editors/awk.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- awk.c	28 Nov 2002 09:30:40 -0000	1.2
+++ awk.c	28 Nov 2002 11:27:23 -0000	1.3
@@ -650,7 +650,7 @@
 		while (hi) {
 			thi = hi;
 			hi = hi->next;
-			if (thi->data.v.string) free(thi->data.v.string);
+			free(thi->data.v.string);
 			free(thi);
 		}
 		array->items[i] = NULL;
@@ -661,7 +661,7 @@
 /* clear a variable */
 static var *clrvar(var *v) {
 
-	if (v->string && !(v->type & VF_FSTR))
+	if (!(v->type & VF_FSTR))
 		free(v->string);
 
 	v->type &= VF_DONTTOUCH;
@@ -1504,7 +1504,7 @@
 		return;
 
 	is_f0_split = TRUE;
-	if (fstrings) free(fstrings);
+	free(fstrings);
 	fsrealloc(0);
 	n = awk_split(getvar_s(V[F0]), &fsplitter.n, &fstrings);
 	fsrealloc(n);
@@ -2376,8 +2376,7 @@
 				X.rsm = (rstream *)hash_search(fdhash, L.s);
 				if (X.rsm) {
 					R.i = X.rsm->is_pipe ? pclose(X.rsm->F) : fclose(X.rsm->F);
-					if (X.rsm->buffer)
-						free(X.rsm->buffer);
+					free(X.rsm->buffer);
 					hash_remove(fdhash, L.s);
 				}
 				if (R.i != 0)

Index: sed.c
===================================================================
RCS file: /var/cvs/busybox/editors/sed.c,v
retrieving revision 1.92
retrieving revision 1.93
diff -u -d -r1.92 -r1.93
--- sed.c	6 Aug 2002 23:13:31 -0000	1.92
+++ sed.c	28 Nov 2002 11:27:23 -0000	1.93
@@ -130,8 +130,7 @@
 			regfree(sed_cmds[ncmds].sub_match);
 			free(sed_cmds[ncmds].sub_match);
 		}
-		if (sed_cmds[ncmds].replace)
-			free(sed_cmds[ncmds].replace);
+		free(sed_cmds[ncmds].replace);
 	}
 
 	/* destroy the array */

Index: vi.c
===================================================================
RCS file: /var/cvs/busybox/editors/vi.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- vi.c	26 Oct 2002 10:19:19 -0000	1.24
+++ vi.c	28 Nov 2002 11:27:23 -0000	1.25
@@ -383,8 +383,7 @@
 	} else {
 		for (; optind < argc; optind++) {
 			editing = 1;	// 0=exit, 1=one file, 2+ =many files
-			if (cfn != 0)
-				free(cfn);
+			free(cfn);
 			cfn = (Byte *) xstrdup(argv[optind]);
 			edit_file(cfn);
 		}
@@ -490,10 +489,8 @@
 	offset = 0;			// no horizontal offset
 	c = '\0';
 #ifdef CONFIG_FEATURE_VI_DOT_CMD
-	if (last_modifying_cmd != 0)
-		free(last_modifying_cmd);
-	if (ioq_start != NULL)
-		free(ioq_start);
+	free(last_modifying_cmd);
+	free(ioq_start);
 	ioq = ioq_start = last_modifying_cmd = 0;
 	adding2q = 0;
 #endif							/* CONFIG_FEATURE_VI_DOT_CMD */
@@ -998,8 +995,7 @@
 		// There is a read-able regular file
 		// make this the current file
 		q = (Byte *) xstrdup((char *) fn);	// save the cfn
-		if (cfn != 0)
-			free(cfn);		// free the old name
+		free(cfn);		// free the old name
 		cfn = q;			// remember new cfn
 
 	  vc5:
@@ -1048,8 +1044,7 @@
 		}
 		if (strlen((char *) args) > 0) {
 			// user wants a new filename
-			if (cfn != NULL)
-				free(cfn);
+			free(cfn);
 			cfn = (Byte *) xstrdup((char *) args);
 		} else {
 			// user wants file status info
@@ -1635,8 +1630,7 @@
 {
 	int li;
 
-	if (screen != 0)
-		free(screen);
+	free(screen);
 	screensize = ro * co + 8;
 	screen = (Byte *) xmalloc(screensize);
 	// initialize the new screen. assume this will be a empty file.
@@ -1652,10 +1646,7 @@
 {
 	if (size < 10240)
 		size = 10240;	// have a minimum size for new files
-	if (text != 0) {
-		//text -= 4;
-		free(text);
-	}
+	free(text);
 	text = (Byte *) xmalloc(size + 8);
 	memset(text, '\0', size);	// clear new text[]
 	//text += 4;		// leave some room for "oops"
@@ -2171,8 +2162,7 @@
 static void start_new_cmd_q(Byte c)
 {
 	// release old cmd
-	if (last_modifying_cmd != 0)
-		free(last_modifying_cmd);
+	free(last_modifying_cmd);
 	// get buffer for new cmd
 	last_modifying_cmd = (Byte *) xmalloc(BUFSIZ);
 	memset(last_modifying_cmd, '\0', BUFSIZ);	// clear new cmd queue
@@ -2227,9 +2217,7 @@
 	}
 	cnt = q - p + 1;
 	t = reg[dest];
-	if (t != 0) {		// if already a yank register
-		free(t);		//   free it
-	}
+	free(t);		//  if already a yank register, free it
 	t = (Byte *) xmalloc(cnt + 1);	// get a new register
 	memset(t, '\0', cnt + 1);	// clear new text[]
 	strncpy((char *) t, (char *) p, cnt);	// copy text[] into bufer
@@ -2615,8 +2603,7 @@
 		}
 	}
 	refresh(FALSE);
-	if (obufp != NULL)
-		free(obufp);
+	free(obufp);
 	obufp = (Byte *) xstrdup((char *) buf);
 	return (obufp);
 }
@@ -3454,9 +3441,7 @@
 			goto dc3;	// if no pat re-use old pat
 		if (strlen((char *) q) > 1) {	// new pat- save it and find
 			// there is a new pat
-			if (last_search_pattern != 0) {
-				free(last_search_pattern);
-			}
+			free(last_search_pattern);
 			last_search_pattern = (Byte *) xstrdup((char *) q);
 			goto dc3;	// now find the pattern
 		}




More information about the busybox-cvs mailing list