comparison src/util.c @ 6053:74b281b4ae29

[gaim-migrate @ 6503] odd man out committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Mon, 07 Jul 2003 14:49:55 +0000
parents a4f2aba0848d
children 6e24de5efdb2
comparison
equal deleted inserted replaced
6052:c062c4bf58ac 6053:74b281b4ae29
439 unsigned char *ascii = NULL; 439 unsigned char *ascii = NULL;
440 440
441 if (!data || !length) 441 if (!data || !length)
442 return NULL; 442 return NULL;
443 443
444 ascii = malloc(length*2 + 1); 444 ascii = g_malloc(length*2 + 1);
445 445
446 for (i=0; i<length; i++) 446 for (i=0; i<length; i++)
447 snprintf(&ascii[i*2], 3, "%02hhx", data[i]); 447 snprintf(&ascii[i*2], 3, "%02hhx", data[i]);
448 448
449 return ascii; 449 return ascii;
458 unsigned char *data; 458 unsigned char *data;
459 459
460 if (!ascii || !(len = strlen(ascii)) || (len % 2)) 460 if (!ascii || !(len = strlen(ascii)) || (len % 2))
461 return 0; 461 return 0;
462 462
463 data = malloc(len/2); 463 data = g_malloc(len/2);
464 for (i=0; i<len; i++) { 464 for (i=0; i<len; i++) {
465 if (!(i % 2)) 465 if (!(i % 2))
466 accumulator = 0; 466 accumulator = 0;
467 else 467 else
468 accumulator = accumulator << 4; 468 accumulator = accumulator << 4;