aboutsummaryrefslogtreecommitdiff
path: root/src/microhttpd/mhd_str.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-03-25 20:59:16 +0100
committerChristian Grothoff <christian@grothoff.org>2017-03-25 20:59:16 +0100
commit11fc9224bd9f88dbf31929222002e5ce90402ec3 (patch)
tree578907dad9c44315bf950e00383767f5ca0a8518 /src/microhttpd/mhd_str.c
parentb8e9408180f5adf70fb759350c073954084186b7 (diff)
downloadlibmicrohttpd-11fc9224bd9f88dbf31929222002e5ce90402ec3.tar.gz
libmicrohttpd-11fc9224bd9f88dbf31929222002e5ce90402ec3.zip
remove dead code converting hex number to size_t
Diffstat (limited to 'src/microhttpd/mhd_str.c')
-rw-r--r--src/microhttpd/mhd_str.c89
1 files changed, 0 insertions, 89 deletions
diff --git a/src/microhttpd/mhd_str.c b/src/microhttpd/mhd_str.c
index 3004c795..22db4e20 100644
--- a/src/microhttpd/mhd_str.c
+++ b/src/microhttpd/mhd_str.c
@@ -454,95 +454,6 @@ MHD_str_to_uint64_n_ (const char * str,
454 454
455 455
456/** 456/**
457 * Convert hexadecimal US-ASCII digits in string to number in size_t.
458 * Conversion stopped at first non-digit character.
459 *
460 * @param str string to convert
461 * @param[out] out_val pointer to size_t to store result of conversion
462 * @return non-zero number of characters processed on succeed,
463 * zero if no digit is found, resulting value is larger
464 * then possible to store in size_t or @a out_val is NULL
465 */
466size_t
467MHD_strx_to_sizet_ (const char *str,
468 size_t *out_val)
469{
470 const char * const start = str;
471 size_t res;
472 int digit;
473
474 if (!str || !out_val)
475 return 0;
476
477 res = 0;
478 digit = toxdigitvalue (*str);
479 while (digit >= 0)
480 {
481 if ( (res < (SIZE_MAX / 16)) ||
482 ( (res == (SIZE_MAX / 16)) &&
483 ((size_t)digit <= (SIZE_MAX % 16)) ) )
484 {
485 res *= 16;
486 res += digit;
487 }
488 else
489 return 0;
490 str++;
491 digit = toxdigitvalue (*str);
492 }
493
494 if (str - start > 0)
495 *out_val = res;
496 return str - start;
497}
498
499
500/**
501 * Convert not more then @a maxlen hexadecimal US-ASCII digits in string
502 * to number in size_t.
503 * Conversion stopped at first non-digit character or after @a maxlen
504 * digits.
505 *
506 * @param str string to convert
507 * @param maxlen maximum number of characters to process
508 * @param[out] out_val pointer to size_t to store result of conversion
509 * @return non-zero number of characters processed on succeed,
510 * zero if no digit is found, resulting value is larger
511 * then possible to store in size_t or @a out_val is NULL
512 */
513size_t
514MHD_strx_to_sizet_n_ (const char * str,
515 size_t maxlen,
516 size_t *out_val)
517{
518 size_t i;
519 size_t res;
520 int digit;
521 if (!str || !out_val)
522 return 0;
523
524 res = 0;
525 i = 0;
526 while ( (i < maxlen) &&
527 ((digit = toxdigitvalue (str[i])) >= 0) )
528 {
529 if ( (res > (SIZE_MAX / 16)) ||
530 ( (res == (SIZE_MAX / 16)) &&
531 ((size_t)digit > (SIZE_MAX % 16)) ) )
532 return 0;
533
534 res *= 16;
535 res += digit;
536 i++;
537 }
538
539 if (i)
540 *out_val = res;
541 return i;
542}
543
544
545/**
546 * Convert hexadecimal US-ASCII digits in string to number in uint32_t. 457 * Convert hexadecimal US-ASCII digits in string to number in uint32_t.
547 * Conversion stopped at first non-digit character. 458 * Conversion stopped at first non-digit character.
548 * 459 *