Download raw body.
[rfc] tog horizontal scroll (diff & blame view)
> Thanks, Theo! I appreciate the tips. Revised patch is below:
Tiny style nit below, then it's ok tb.
>
> diff a75b3e2dd76c9392eb52ae19ef339a13f32eb821 /Users/mark/Library/Mobile Documents/com~apple~CloudDocs/src/got-hscroll
> blob - 8a28476cd4abc2585e93d816ed8368b82925038b
> file + tog/tog.c
> --- tog/tog.c
> +++ tog/tog.c
> @@ -1232,7 +1232,7 @@ expand_tab(char **ptr, const char *src)
>
> *ptr = NULL;
> n = len = strlen(src);
> - dst = malloc((n + 1) * sizeof(char));
> + dst = malloc(n + 1);
> if (dst == NULL)
> return got_error_from_errno("malloc");
>
> @@ -1241,11 +1241,15 @@ expand_tab(char **ptr, const char *src)
>
> if (c == '\t') {
> size_t nb = TABSIZE - sz % TABSIZE;
> + char *p = realloc(dst, n + nb);
style(9) tells us not to use function calls in initializers, so split
declaration and assignment. And please leave a blank after the variable
declarations:
size_t nb = ...;
char *p;
p = realloc(dst, n + nb);
> + if (p == NULL) {
> + free(dst);
> + return got_error_from_errno("realloc");
> +
> + }
> + dst = p;
> n += nb;
> - dst = reallocarray(dst, n, sizeof(char));
> - if (dst == NULL)
> - return got_error_from_errno("reallocarray");
> - memcpy(dst + sz, " ", nb);
> + memset(dst + sz, ' ', nb);
> sz += nb;
> } else
> dst[sz++] = src[idx];
>
>
> --
> Mark Jamsek <fnc.bsdbox.org>
> GPG: F2FF 13DE 6A06 C471 CA80 E6E2 2930 DC66 86EE CF68
[rfc] tog horizontal scroll (diff & blame view)