diff src/util.c @ 79:bfdc427b936d

[gaim-migrate @ 89] I'll save time and just post the email :-) Summary of changes: * Misc malloc/free cleanups, use g_malloc more places and other small stuff (e.g. lineardata not being freed in the error case in sound.c) * Misc signed/unsigned cleanups (use size_t more often) * read() can return -1 at any point, check return values more rigorously (read_rv variables used for this) * In can_play_audio, stat requires a pointer to an allocated stat_buf (the address of an automatic variable) * escape_text needs a buffer at least 4 times the size of the text being passed in (not 2 times); I can force core dumps with lots of newlines otherwise * There's a debug statement in netscape_command (browser.c) that was printf("Hello%d\n"); with no int for the %d; I threw in a getppid(), but the statement should probably come out eventually. Thanks, G Sumner Hayes! committer: Tailor Script <tailor@pidgin.im>
author Rob Flynn <gaim@robflynn.com>
date Wed, 05 Apr 2000 05:34:08 +0000
parents dead1eb6d654
children 0ff9f19b9b23
line wrap: on
line diff
--- a/src/util.c	Fri Mar 31 20:22:12 2000 +0000
+++ b/src/util.c	Wed Apr 05 05:34:08 2000 +0000
@@ -303,8 +303,8 @@
 
 FILE *open_log_file (struct conversation *c)
 {
-        char *buf = g_malloc(BUF_LONG);
-        char *buf2 = g_malloc(BUF_LONG);
+        char *buf;
+        char *buf2;
         char log_all_file[256];
         struct log_conversation *l;
         struct stat st;
@@ -314,9 +314,6 @@
 
         if (!(general_options & OPT_GEN_LOG_ALL)) {
 
-		g_free(buf);
-		g_free(buf2);
-
                 l = find_log_info(c->name);
                 if (!l)
                         return NULL;
@@ -335,6 +332,9 @@
                 return fd;
         }
 
+	buf = g_malloc(BUF_LONG);
+	buf2 = g_malloc(BUF_LONG);
+
         /*  Dont log yourself */
         g_snprintf(log_all_file, 256, "%s/.gaim", getenv("HOME"));
 
@@ -436,7 +436,7 @@
 {
 	char *c, *cpy;
 	int cnt=0;
-	/* Assumes you have a buffer able to cary at least BUF_LEN * 2 bytes */
+	/* Assumes you have a buffer able to cary at least BUF_LEN * 4 bytes */
 	if (strlen(msg) > BUF_LEN) {
 		fprintf(stderr, "Warning:  truncating message to 2048 bytes\n");
 		msg[2047]='\0';
@@ -479,7 +479,7 @@
                 msg[2047]='\0';
         }
 
-	woo = (char *)malloc(strlen(msg) * 2); 
+	woo = malloc(strlen(msg) * 2); 
         cpy = g_strdup(msg);
         c = cpy;
         while(*c) {
@@ -629,7 +629,7 @@
         char *t, *u;
         int x=0;
 
-        g_return_if_fail (s != NULL);
+        g_return_val_if_fail ((s != NULL), NULL);
 
         u = t = g_strdup(s);