X-Git-Url: http://sjero.net/git/?a=blobdiff_plain;f=src%2Fres.c;h=f8add49cf574b56dcf086e42355afcae7527945e;hb=5f0a2b3f0846dd4c2f72fc62e7171200d1fd6e06;hp=6e3da1441a4ad049df1f352c9a3b6d7b62885d36;hpb=b2be7522c745827b521a8ed535201427df32eec7;p=wget diff --git a/src/res.c b/src/res.c index 6e3da144..f8add49c 100644 --- a/src/res.c +++ b/src/res.c @@ -167,7 +167,7 @@ prune_non_exact (struct robot_specs *specs) for (i = 0; i < specs->count; i++) if (specs->paths[i].user_agent_exact_p) ++cnt; - newpaths = xmalloc (cnt * sizeof (struct path_info)); + newpaths = xnew_array (struct path_info, cnt); for (i = 0, j = 0; i < specs->count; i++) if (specs->paths[i].user_agent_exact_p) newpaths[j++] = specs->paths[i]; @@ -240,8 +240,7 @@ res_parse (const char *source, int length) the last `user-agent' instructions. */ int record_count = 0; - struct robot_specs *specs = xmalloc (sizeof (struct robot_specs)); - memset (specs, '\0', sizeof (struct robot_specs)); + struct robot_specs *specs = xnew0 (struct robot_specs); while (1) { @@ -417,17 +416,16 @@ free_specs (struct robot_specs *specs) that number is not a numerical representation of '/', decode C and advance the pointer. */ -#define DECODE_MAYBE(c, ptr) do { \ - if (c == '%' && ISXDIGIT (ptr[1]) && ISXDIGIT (ptr[2])) \ - { \ - char decoded \ - = (XCHAR_TO_XDIGIT (ptr[1]) << 4) + XCHAR_TO_XDIGIT (ptr[2]); \ - if (decoded != '/') \ - { \ - c = decoded; \ - ptr += 2; \ - } \ - } \ +#define DECODE_MAYBE(c, ptr) do { \ + if (c == '%' && ISXDIGIT (ptr[1]) && ISXDIGIT (ptr[2])) \ + { \ + char decoded = X2DIGITS_TO_NUM (ptr[1], ptr[2]); \ + if (decoded != '/') \ + { \ + c = decoded; \ + ptr += 2; \ + } \ + } \ } while (0) /* The inner matching engine: return non-zero if RECORD_PATH matches