comparison src/proxy.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 2846a03bda67
children ec0686b3b03f
comparison
equal deleted inserted replaced
78:66c5a24b62ec 79:bfdc427b936d
48 int c; 48 int c;
49 char *result; 49 char *result;
50 size_t input_index = 0; 50 size_t input_index = 0;
51 size_t result_size = 80; 51 size_t result_size = 80;
52 52
53 result = (char *) malloc (result_size); 53 result = g_malloc (result_size);
54 54
55 while (1) 55 while (1)
56 { 56 {
57 char ch; 57 char ch;
58 if (recv (sock, &ch, 1, 0) < 0) 58 if (recv (sock, &ch, 1, 0) < 0)
59 fprintf (stderr, "recv() error from proxy server\n"); 59 fprintf (stderr, "recv() error from proxy server\n");
60 c = ch; 60 c = ch;
61 61
62 if (c == EOF) 62 if (c == EOF)
63 { 63 {
64 free (result); 64 g_free (result);
65 65
66 /* It's end of file. */ 66 /* It's end of file. */
67 fprintf(stderr, "end of file from server\n"); 67 fprintf(stderr, "end of file from server\n");
68 } 68 }
69 69
72 72
73 result[input_index++] = c; 73 result[input_index++] = c;
74 while (input_index + 1 >= result_size) 74 while (input_index + 1 >= result_size)
75 { 75 {
76 result_size *= 2; 76 result_size *= 2;
77 result = (char *) realloc (result, result_size); 77 result = (char *) g_realloc (result, result_size);
78 } 78 }
79 } 79 }
80 80
81 if (resultp) 81 if (resultp)
82 *resultp = result; 82 *resultp = result;
83 83
84 /* Terminate it just for kicks, but we *can* deal with embedded NULs. */ 84 /* Terminate it just for kicks, but we *can* deal with embedded NULs. */
85 result[input_index] = '\0'; 85 result[input_index] = '\0';
86 86
87 if (resultp == NULL) 87 if (resultp == NULL)
88 free (result); 88 g_free (result);
89 return input_index; 89 return input_index;
90 } 90 }
91 91
92 92
93 struct hostent *proxy_gethostbyname(char *host) 93 struct hostent *proxy_gethostbyname(char *host)