Use size_t consistently and complete some uncompleted code resulting in a
memory leak by assigning and freeing a variable appropriately as well as keeping track of the amount of allocated ram properly. MFC after: 1 month
This commit is contained in:
parent
d7b8563d55
commit
6953dff37c
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=98468
@ -35,7 +35,7 @@
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
int cnt;
|
||||
size_t cnt;
|
||||
char *buf;
|
||||
} BUF;
|
||||
|
||||
|
@ -670,14 +670,17 @@ sink(int argc, char *argv[])
|
||||
if (*cp++ != ' ')
|
||||
SCREWUP("size not delimited");
|
||||
if (targisdir) {
|
||||
static char *namebuf;
|
||||
static int cursize;
|
||||
static char *namebuf = NULL;
|
||||
static size_t cursize;
|
||||
size_t need;
|
||||
|
||||
need = strlen(targ) + strlen(cp) + 250;
|
||||
if (need > cursize) {
|
||||
if (namebuf != NULL)
|
||||
free(namebuf);
|
||||
if (!(namebuf = malloc(need)))
|
||||
run_err("%s", strerror(errno));
|
||||
cursize = need;
|
||||
}
|
||||
(void)snprintf(namebuf, need, "%s%s%s", targ,
|
||||
*targ ? "/" : "", cp);
|
||||
|
Loading…
Reference in New Issue
Block a user