From: Mark Jamsek Subject: Re: [rfc] tog horizontal scroll (diff & blame view) To: Theo Buehler Cc: gameoftrees@openbsd.org Date: Fri, 17 Jun 2022 01:21:40 +1000 On 22-06-16 02:29pm, Theo Buehler wrote: > > 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); > This has also been committed. Thanks for this, Theo. I just gave myself a style(9) refresher so I shouldn't forget again. -- Mark Jamsek GPG: F2FF 13DE 6A06 C471 CA80 E6E2 2930 DC66 86EE CF68