free all allocated items, use %zu for size_t
b43ec057
`items` itself is not checked for NULL as calling free on NULL is defined to be a no-op.
1 file(s) · +6 −3
`items` itself is not checked for NULL as calling free on NULL is defined to be a no-op.
| 104 | 104 | XUngrabKey(dpy, AnyKey, AnyModifier, root); |
|
| 105 | 105 | for (i = 0; i < SchemeLast; i++) |
|
| 106 | 106 | free(scheme[i]); |
|
| 107 | + | for (i = 0; items && items[i].text; ++i) |
|
| 108 | + | free(items[i].text); |
|
| 109 | + | free(items); |
|
| 107 | 110 | drw_free(drw); |
|
| 108 | 111 | XSync(dpy, False); |
|
| 109 | 112 | XCloseDisplay(dpy); |
|
| 239 | 242 | /* separate input text into tokens to be matched individually */ |
|
| 240 | 243 | for (s = strtok(buf, " "); s; tokv[tokc - 1] = s, s = strtok(NULL, " ")) |
|
| 241 | 244 | if (++tokc > tokn && !(tokv = realloc(tokv, ++tokn * sizeof *tokv))) |
|
| 242 | - | die("cannot realloc %u bytes:", tokn * sizeof *tokv); |
|
| 245 | + | die("cannot realloc %zu bytes:", tokn * sizeof *tokv); |
|
| 243 | 246 | len = tokc ? strlen(tokv[0]) : 0; |
|
| 244 | 247 | ||
| 245 | 248 | matches = lprefix = lsubstr = matchend = prefixend = substrend = NULL; |
|
| 553 | 556 | for (i = 0; fgets(buf, sizeof buf, stdin); i++) { |
|
| 554 | 557 | if (i + 1 >= size / sizeof *items) |
|
| 555 | 558 | if (!(items = realloc(items, (size += BUFSIZ)))) |
|
| 556 | - | die("cannot realloc %u bytes:", size); |
|
| 559 | + | die("cannot realloc %zu bytes:", size); |
|
| 557 | 560 | if ((p = strchr(buf, '\n'))) |
|
| 558 | 561 | *p = '\0'; |
|
| 559 | 562 | if (!(items[i].text = strdup(buf))) |
|
| 560 | - | die("cannot strdup %u bytes:", strlen(buf) + 1); |
|
| 563 | + | die("cannot strdup %zu bytes:", strlen(buf) + 1); |
|
| 561 | 564 | items[i].out = 0; |
|
| 562 | 565 | } |
|
| 563 | 566 | if (items) |
|