Mercurial > pidgin
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 78:66c5a24b62ec | 79:bfdc427b936d |
|---|---|
| 301 } | 301 } |
| 302 | 302 |
| 303 | 303 |
| 304 FILE *open_log_file (struct conversation *c) | 304 FILE *open_log_file (struct conversation *c) |
| 305 { | 305 { |
| 306 char *buf = g_malloc(BUF_LONG); | 306 char *buf; |
| 307 char *buf2 = g_malloc(BUF_LONG); | 307 char *buf2; |
| 308 char log_all_file[256]; | 308 char log_all_file[256]; |
| 309 struct log_conversation *l; | 309 struct log_conversation *l; |
| 310 struct stat st; | 310 struct stat st; |
| 311 int flag = 0; | 311 int flag = 0; |
| 312 FILE *fd; | 312 FILE *fd; |
| 313 int res; | 313 int res; |
| 314 | 314 |
| 315 if (!(general_options & OPT_GEN_LOG_ALL)) { | 315 if (!(general_options & OPT_GEN_LOG_ALL)) { |
| 316 | 316 |
| 317 g_free(buf); | |
| 318 g_free(buf2); | |
| 319 | |
| 320 l = find_log_info(c->name); | 317 l = find_log_info(c->name); |
| 321 if (!l) | 318 if (!l) |
| 322 return NULL; | 319 return NULL; |
| 323 | 320 |
| 324 if (stat(l->filename, &st) < 0) | 321 if (stat(l->filename, &st) < 0) |
| 332 fprintf(fd, "</TITLE></HEAD><BODY BGCOLOR=\"ffffff\">\n" ); | 329 fprintf(fd, "</TITLE></HEAD><BODY BGCOLOR=\"ffffff\">\n" ); |
| 333 } | 330 } |
| 334 | 331 |
| 335 return fd; | 332 return fd; |
| 336 } | 333 } |
| 334 | |
| 335 buf = g_malloc(BUF_LONG); | |
| 336 buf2 = g_malloc(BUF_LONG); | |
| 337 | 337 |
| 338 /* Dont log yourself */ | 338 /* Dont log yourself */ |
| 339 g_snprintf(log_all_file, 256, "%s/.gaim", getenv("HOME")); | 339 g_snprintf(log_all_file, 256, "%s/.gaim", getenv("HOME")); |
| 340 | 340 |
| 341 stat(log_all_file, &st); | 341 stat(log_all_file, &st); |
| 434 | 434 |
| 435 int escape_text(char *msg) | 435 int escape_text(char *msg) |
| 436 { | 436 { |
| 437 char *c, *cpy; | 437 char *c, *cpy; |
| 438 int cnt=0; | 438 int cnt=0; |
| 439 /* Assumes you have a buffer able to cary at least BUF_LEN * 2 bytes */ | 439 /* Assumes you have a buffer able to cary at least BUF_LEN * 4 bytes */ |
| 440 if (strlen(msg) > BUF_LEN) { | 440 if (strlen(msg) > BUF_LEN) { |
| 441 fprintf(stderr, "Warning: truncating message to 2048 bytes\n"); | 441 fprintf(stderr, "Warning: truncating message to 2048 bytes\n"); |
| 442 msg[2047]='\0'; | 442 msg[2047]='\0'; |
| 443 } | 443 } |
| 444 | 444 |
| 477 if (strlen(msg) > BUF_LEN) { | 477 if (strlen(msg) > BUF_LEN) { |
| 478 fprintf(stderr, "Warning: truncating message to 2048 bytes\n"); | 478 fprintf(stderr, "Warning: truncating message to 2048 bytes\n"); |
| 479 msg[2047]='\0'; | 479 msg[2047]='\0'; |
| 480 } | 480 } |
| 481 | 481 |
| 482 woo = (char *)malloc(strlen(msg) * 2); | 482 woo = malloc(strlen(msg) * 2); |
| 483 cpy = g_strdup(msg); | 483 cpy = g_strdup(msg); |
| 484 c = cpy; | 484 c = cpy; |
| 485 while(*c) { | 485 while(*c) { |
| 486 switch(*c) { | 486 switch(*c) { |
| 487 case '\n': | 487 case '\n': |
| 627 { | 627 { |
| 628 static char buf[BUF_LEN]; | 628 static char buf[BUF_LEN]; |
| 629 char *t, *u; | 629 char *t, *u; |
| 630 int x=0; | 630 int x=0; |
| 631 | 631 |
| 632 g_return_if_fail (s != NULL); | 632 g_return_val_if_fail ((s != NULL), NULL); |
| 633 | 633 |
| 634 u = t = g_strdup(s); | 634 u = t = g_strdup(s); |
| 635 | 635 |
| 636 strcpy(t, s); | 636 strcpy(t, s); |
| 637 g_strdown(t); | 637 g_strdown(t); |
