comparison src/util.c @ 5497:3c7748b24410

[gaim-migrate @ 5893] I changed some small things. 1) 3 comments in 3 different files which makes "make docs" not give 3 warnings. 2) Made frombase16 return-via-parameter an unsigned char* instead of a char*. Nothing actually uses frombase16, so this doesn't affect anything, but it mirrors Nathan's change to tobase16, and should make the conversion work correctly. 3) Fixed the bug Luke mailed to gaim-devel on Monday: "sign on, change an aim account's email address, sign off, segfault. it's happened 2x now" --Luke "The Yellow Dart" Schierer committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Fri, 23 May 2003 01:45:17 +0000
parents e1cc0c67e123
children 439a05a6b409
comparison
equal deleted inserted replaced
5496:b7c0be69c749 5497:3c7748b24410
484 } 484 }
485 485
486 /* 486 /*
487 * Converts a null-terminated string of hexidecimal to raw data. 487 * Converts a null-terminated string of hexidecimal to raw data.
488 */ 488 */
489 int frombase16(const char *ascii, char **raw) 489 int frombase16(const char *ascii, unsigned char **raw)
490 { 490 {
491 int len, i, accumulator=0; 491 int len, i, accumulator=0;
492 char *data; 492 unsigned char *data;
493 493
494 if (!ascii || !(len = strlen(ascii)) || (len % 2)) 494 if (!ascii || !(len = strlen(ascii)) || (len % 2))
495 return 0; 495 return 0;
496 496
497 data = (char *)malloc((len/2)*sizeof(char)); 497 data = malloc(len/2);
498 for (i=0; i<len; i++) { 498 for (i=0; i<len; i++) {
499 if (!(i % 2)) 499 if (!(i % 2))
500 accumulator = 0; 500 accumulator = 0;
501 else 501 else
502 accumulator = accumulator << 4; 502 accumulator = accumulator << 4;