diff src/sound.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 b1d7336cba85
children 05077cb276d4
line wrap: on
line diff
--- a/src/sound.c	Fri Mar 31 20:22:12 2000 +0000
+++ b/src/sound.c	Wed Apr 05 05:34:08 2000 +0000
@@ -60,16 +60,16 @@
 
 static int can_play_audio()
 {
-	struct stat *stat_buf;
+	struct stat stat_buf;
 	uid_t user = getuid();
 	gid_t group = getgid(); 
-	if (stat("/dev/audio", stat_buf))
+	if (stat("/dev/audio", &stat_buf))
 		return 0;
-	if (user == stat_buf->st_uid && stat_buf->st_mode & S_IWUSR)
+	if (user == stat_buf.st_uid && stat_buf.st_mode & S_IWUSR)
 		return 1;
-	if (group == stat_buf->st_gid && stat_buf->st_mode & S_IWGRP)
+	if (group == stat_buf.st_gid && stat_buf.st_mode & S_IWGRP)
 		return 1;
-	if (stat_buf->st_mode & S_IWOTH)
+	if (stat_buf.st_mode & S_IWOTH)
 		return 1;
 	return 0;
 }
@@ -114,13 +114,16 @@
 {
         int fd, i;
 	esd_format_t format = ESD_BITS16 | ESD_STREAM | ESD_PLAY | ESD_MONO;
-        guint16 *lineardata = g_malloc(size * 2);
+        guint16 *lineardata;
 	
 	
         fd = esd_play_stream(format, 8012, NULL, "gaim");
 
-        if (fd < 0)
+        if (fd < 0) {
                 return 0;
+	}
+
+        lineardata = g_malloc(size * 2);
 
 	for (i=0; i<size; i++)
 		lineardata[i] = _af_ulaw2linear(data[i]);