Module Name: src
Committed By: christos
Date: Thu Jul 28 20:50:55 UTC 2011
Modified Files:
src/lib/libedit: chared.c chartype.c el.c eln.c filecomplete.c hist.c
hist.h histedit.h history.c keymacro.c map.c read.c readline.c
search.c sig.c sys.h terminal.c tokenizer.c vi.c
Log Message:
kill ptr_t and ioctl_t, add * sizeof(*foo) to all allocations.
To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/lib/libedit/chared.c
cvs rdiff -u -r1.6 -r1.7 src/lib/libedit/chartype.c
cvs rdiff -u -r1.66 -r1.67 src/lib/libedit/el.c
cvs rdiff -u -r1.11 -r1.12 src/lib/libedit/eln.c
cvs rdiff -u -r1.25 -r1.26 src/lib/libedit/filecomplete.c \
src/lib/libedit/search.c
cvs rdiff -u -r1.18 -r1.19 src/lib/libedit/hist.c src/lib/libedit/tokenizer.c
cvs rdiff -u -r1.12 -r1.13 src/lib/libedit/hist.h
cvs rdiff -u -r1.47 -r1.48 src/lib/libedit/histedit.h
cvs rdiff -u -r1.41 -r1.42 src/lib/libedit/history.c
cvs rdiff -u -r1.3 -r1.4 src/lib/libedit/keymacro.c \
src/lib/libedit/terminal.c
cvs rdiff -u -r1.27 -r1.28 src/lib/libedit/map.c
cvs rdiff -u -r1.63 -r1.64 src/lib/libedit/read.c
cvs rdiff -u -r1.94 -r1.95 src/lib/libedit/readline.c
cvs rdiff -u -r1.16 -r1.17 src/lib/libedit/sig.c
cvs rdiff -u -r1.14 -r1.15 src/lib/libedit/sys.h
cvs rdiff -u -r1.35 -r1.36 src/lib/libedit/vi.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/lib/libedit/chared.c
diff -u src/lib/libedit/chared.c:1.30 src/lib/libedit/chared.c:1.31
--- src/lib/libedit/chared.c:1.30 Wed Jul 27 21:05:20 2011
+++ src/lib/libedit/chared.c Thu Jul 28 16:50:55 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: chared.c,v 1.30 2011/07/28 01:05:20 christos Exp $ */
+/* $NetBSD: chared.c,v 1.31 2011/07/28 20:50:55 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)chared.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: chared.c,v 1.30 2011/07/28 01:05:20 christos Exp $");
+__RCSID("$NetBSD: chared.c,v 1.31 2011/07/28 20:50:55 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -544,7 +544,7 @@
{
c_macro_t *ma = &el->el_chared.c_macro;
while (ma->level >= 0)
- el_free((ptr_t)ma->macro[ma->level--]);
+ el_free(ma->macro[ma->level--]);
}
/* ch_enlargebufs():
@@ -589,7 +589,8 @@
/*
* Reallocate kill buffer.
*/
- newbuffer = el_realloc(el->el_chared.c_kill.buf, newsz * sizeof(*newbuffer));
+ newbuffer = el_realloc(el->el_chared.c_kill.buf, newsz *
+ sizeof(*newbuffer));
if (!newbuffer)
return 0;
@@ -642,20 +643,20 @@
protected void
ch_end(EditLine *el)
{
- el_free((ptr_t) el->el_line.buffer);
+ el_free(el->el_line.buffer);
el->el_line.buffer = NULL;
el->el_line.limit = NULL;
- el_free((ptr_t) el->el_chared.c_undo.buf);
+ el_free(el->el_chared.c_undo.buf);
el->el_chared.c_undo.buf = NULL;
- el_free((ptr_t) el->el_chared.c_redo.buf);
+ el_free(el->el_chared.c_redo.buf);
el->el_chared.c_redo.buf = NULL;
el->el_chared.c_redo.pos = NULL;
el->el_chared.c_redo.lim = NULL;
el->el_chared.c_redo.cmd = ED_UNASSIGNED;
- el_free((ptr_t) el->el_chared.c_kill.buf);
+ el_free(el->el_chared.c_kill.buf);
el->el_chared.c_kill.buf = NULL;
ch_reset(el, 1);
- el_free((ptr_t) el->el_chared.c_macro.macro);
+ el_free(el->el_chared.c_macro.macro);
el->el_chared.c_macro.macro = NULL;
}
Index: src/lib/libedit/chartype.c
diff -u src/lib/libedit/chartype.c:1.6 src/lib/libedit/chartype.c:1.7
--- src/lib/libedit/chartype.c:1.6 Wed Jul 27 20:48:21 2011
+++ src/lib/libedit/chartype.c Thu Jul 28 16:50:55 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: chartype.c,v 1.6 2011/07/28 00:48:21 christos Exp $ */
+/* $NetBSD: chartype.c,v 1.7 2011/07/28 20:50:55 christos Exp $ */
/*-
* Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
*/
#include "config.h"
#if !defined(lint) && !defined(SCCSID)
-__RCSID("$NetBSD: chartype.c,v 1.6 2011/07/28 00:48:21 christos Exp $");
+__RCSID("$NetBSD: chartype.c,v 1.7 2011/07/28 20:50:55 christos Exp $");
#endif /* not lint && not SCCSID */
#include "el.h"
#include <stdlib.h>
@@ -52,7 +52,7 @@
void *p;
if (mincsize > conv->csize) {
conv->csize = mincsize;
- p = el_realloc(conv->cbuff, conv->csize * sizeof(char));
+ p = el_realloc(conv->cbuff, conv->csize * sizeof(*conv->cbuff));
if (p == NULL) {
conv->csize = 0;
el_free(conv->cbuff);
@@ -63,7 +63,7 @@
if (minwsize > conv->wsize) {
conv->wsize = minwsize;
- p = el_realloc(conv->wbuff, conv->wsize * sizeof(Char));
+ p = el_realloc(conv->wbuff, conv->wsize * sizeof(*conv->wbuff));
if (p == NULL) {
conv->wsize = 0;
el_free(conv->wbuff);
Index: src/lib/libedit/el.c
diff -u src/lib/libedit/el.c:1.66 src/lib/libedit/el.c:1.67
--- src/lib/libedit/el.c:1.66 Wed Jul 27 21:56:27 2011
+++ src/lib/libedit/el.c Thu Jul 28 16:50:55 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: el.c,v 1.66 2011/07/28 01:56:27 christos Exp $ */
+/* $NetBSD: el.c,v 1.67 2011/07/28 20:50:55 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)el.c 8.2 (Berkeley) 1/3/94";
#else
-__RCSID("$NetBSD: el.c,v 1.66 2011/07/28 01:56:27 christos Exp $");
+__RCSID("$NetBSD: el.c,v 1.67 2011/07/28 20:50:55 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -60,7 +60,7 @@
public EditLine *
el_init(const char *prog, FILE *fin, FILE *fout, FILE *ferr)
{
- EditLine *el = (EditLine *) el_malloc(sizeof(EditLine));
+ EditLine *el = el_malloc(sizeof(*el));
if (el == NULL)
return (NULL);
@@ -134,14 +134,14 @@
prompt_end(el);
sig_end(el);
- el_free((ptr_t) el->el_prog);
+ el_free(el->el_prog);
#ifdef WIDECHAR
- el_free((ptr_t) el->el_scratch.cbuff);
- el_free((ptr_t) el->el_scratch.wbuff);
- el_free((ptr_t) el->el_lgcyconv.cbuff);
- el_free((ptr_t) el->el_lgcyconv.wbuff);
+ el_free(el->el_scratch.cbuff);
+ el_free(el->el_scratch.wbuff);
+ el_free(el->el_lgcyconv.cbuff);
+ el_free(el->el_lgcyconv.wbuff);
#endif
- el_free((ptr_t) el);
+ el_free(el);
}
@@ -270,7 +270,7 @@
case EL_HIST:
{
hist_fun_t func = va_arg(ap, hist_fun_t);
- ptr_t ptr = va_arg(ap, ptr_t);
+ void *ptr = va_arg(ap, void *);
rv = hist_set(el, func, ptr);
if (!(el->el_flags & CHARSET_IS_UTF8))
@@ -521,7 +521,7 @@
if ((ptr = getenv("HOME")) == NULL)
return (-1);
plen += strlen(ptr);
- if ((path = malloc(plen)) == NULL)
+ if ((path = el_malloc(plen * sizeof(*path))) == NULL)
return (-1);
(void)snprintf(path, plen, "%s%s", ptr, elpath);
fname = path;
Index: src/lib/libedit/eln.c
diff -u src/lib/libedit/eln.c:1.11 src/lib/libedit/eln.c:1.12
--- src/lib/libedit/eln.c:1.11 Wed Jul 27 21:05:20 2011
+++ src/lib/libedit/eln.c Thu Jul 28 16:50:55 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: eln.c,v 1.11 2011/07/28 01:05:20 christos Exp $ */
+/* $NetBSD: eln.c,v 1.12 2011/07/28 20:50:55 christos Exp $ */
/*-
* Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
*/
#include "config.h"
#if !defined(lint) && !defined(SCCSID)
-__RCSID("$NetBSD: eln.c,v 1.11 2011/07/28 01:05:20 christos Exp $");
+__RCSID("$NetBSD: eln.c,v 1.12 2011/07/28 20:50:55 christos Exp $");
#endif /* not lint && not SCCSID */
#include "histedit.h"
@@ -215,7 +215,7 @@
}
case EL_HIST: { /* hist_fun_t, const char * */
hist_fun_t fun = va_arg(ap, hist_fun_t);
- ptr_t ptr = va_arg(ap, ptr_t);
+ void *ptr = va_arg(ap, void *);
ret = hist_set(el, fun, ptr);
el->el_flags |= NARROW_HISTORY;
break;
Index: src/lib/libedit/filecomplete.c
diff -u src/lib/libedit/filecomplete.c:1.25 src/lib/libedit/filecomplete.c:1.26
--- src/lib/libedit/filecomplete.c:1.25 Thu Jul 28 13:33:55 2011
+++ src/lib/libedit/filecomplete.c Thu Jul 28 16:50:55 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: filecomplete.c,v 1.25 2011/07/28 17:33:55 christos Exp $ */
+/* $NetBSD: filecomplete.c,v 1.26 2011/07/28 20:50:55 christos Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
#include "config.h"
#if !defined(lint) && !defined(SCCSID)
-__RCSID("$NetBSD: filecomplete.c,v 1.25 2011/07/28 17:33:55 christos Exp $");
+__RCSID("$NetBSD: filecomplete.c,v 1.26 2011/07/28 20:50:55 christos Exp $");
#endif /* not lint && not SCCSID */
#include <sys/types.h>
@@ -91,7 +91,7 @@
return NULL;
} else {
len = temp - txt + 1; /* text until string after slash */
- temp = malloc(len);
+ temp = el_malloc(len * sizeof(*temp));
if (temp == NULL)
return NULL;
(void)strncpy(temp, txt + 1, len - 2);
@@ -117,7 +117,7 @@
pass = getpwnam(temp);
#endif
}
- free(temp); /* value no more needed */
+ el_free(temp); /* value no more needed */
if (pass == NULL)
return (strdup(txt));
@@ -125,10 +125,11 @@
/* first slash */
txt += len;
- temp = malloc(strlen(pass->pw_dir) + 1 + strlen(txt) + 1);
+ len = strlen(pass->pw_dir) + 1 + strlen(txt) + 1;
+ temp = el_malloc(len * sizeof(*temp));
if (temp == NULL)
return NULL;
- (void)sprintf(temp, "%s/%s", pass->pw_dir, txt);
+ (void)snprintf(temp, len, "%s/%s", pass->pw_dir, txt);
return (temp);
}
@@ -156,9 +157,10 @@
if (temp) {
char *nptr;
temp++;
- nptr = realloc(filename, strlen(temp) + 1);
+ nptr = el_realloc(filename, (strlen(temp) + 1) *
+ sizeof(*nptr));
if (nptr == NULL) {
- free(filename);
+ el_free(filename);
filename = NULL;
return NULL;
}
@@ -166,9 +168,10 @@
(void)strcpy(filename, temp);
len = temp - text; /* including last slash */
- nptr = realloc(dirname, len + 1);
+ nptr = el_realloc(dirname, (len + 1) *
+ sizeof(*nptr));
if (nptr == NULL) {
- free(dirname);
+ el_free(dirname);
dirname = NULL;
return NULL;
}
@@ -176,7 +179,7 @@
(void)strncpy(dirname, text, len);
dirname[len] = '\0';
} else {
- free(filename);
+ el_free(filename);
if (*text == 0)
filename = NULL;
else {
@@ -184,7 +187,7 @@
if (filename == NULL)
return NULL;
}
- free(dirname);
+ el_free(dirname);
dirname = NULL;
}
@@ -195,7 +198,7 @@
/* support for ``~user'' syntax */
- free(dirpath);
+ el_free(dirpath);
dirpath = NULL;
if (dirname == NULL) {
if ((dirname = strdup("")) == NULL)
@@ -246,10 +249,11 @@
len = strlen(entry->d_name);
#endif
- temp = malloc(strlen(dirname) + len + 1);
+ len = strlen(dirname) + len + 1;
+ temp = el_malloc(len * sizeof(*temp));
if (temp == NULL)
return NULL;
- (void)sprintf(temp, "%s%s", dirname, entry->d_name);
+ (void)snprintf(temp, len, "%s%s", dirname, entry->d_name);
} else {
(void)closedir(dir);
dir = NULL;
@@ -273,7 +277,7 @@
rs = "/";
out:
if (expname)
- free(expname);
+ el_free(expname);
return rs;
}
/*
@@ -296,10 +300,10 @@
char **nmatch_list;
while (matches + 3 >= match_list_len)
match_list_len <<= 1;
- nmatch_list = realloc(match_list,
- match_list_len * sizeof(char *));
+ nmatch_list = el_realloc(match_list,
+ match_list_len * sizeof(*nmatch_list));
if (nmatch_list == NULL) {
- free(match_list);
+ el_free(match_list);
return NULL;
}
match_list = nmatch_list;
@@ -322,9 +326,9 @@
max_equal = i;
}
- retstr = malloc(max_equal + 1);
+ retstr = el_malloc((max_equal + 1) * sizeof(*retstr));
if (retstr == NULL) {
- free(match_list);
+ el_free(match_list);
return NULL;
}
(void)strncpy(retstr, match_list[1], max_equal);
@@ -445,7 +449,7 @@
ctemp--;
len = li->cursor - ctemp;
- temp = malloc(sizeof(*temp) * (len + 1));
+ temp = el_malloc((len + 1) * sizeof(*temp));
(void)Strncpy(temp, ctemp, len);
temp[len] = '\0';
@@ -556,11 +560,11 @@
/* free elements of array and the array itself */
for (i = 0; matches[i]; i++)
- free(matches[i]);
- free(matches);
+ el_free(matches[i]);
+ el_free(matches);
matches = NULL;
}
- free(temp);
+ el_free(temp);
return retval;
}
Index: src/lib/libedit/search.c
diff -u src/lib/libedit/search.c:1.25 src/lib/libedit/search.c:1.26
--- src/lib/libedit/search.c:1.25 Wed Jul 27 20:46:26 2011
+++ src/lib/libedit/search.c Thu Jul 28 16:50:55 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: search.c,v 1.25 2011/07/28 00:46:26 christos Exp $ */
+/* $NetBSD: search.c,v 1.26 2011/07/28 20:50:55 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)search.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: search.c,v 1.25 2011/07/28 00:46:26 christos Exp $");
+__RCSID("$NetBSD: search.c,v 1.26 2011/07/28 20:50:55 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -86,7 +86,7 @@
search_end(EditLine *el)
{
- el_free((ptr_t) el->el_search.patbuf);
+ el_free(el->el_search.patbuf);
el->el_search.patbuf = NULL;
}
@@ -137,7 +137,7 @@
#elif defined(REGEXP)
if ((re = regcomp(ct_encode_string(pat, &conv))) != NULL) {
rv = regexec(re, ct_encode_string(str, &conv));
- free((ptr_t) re);
+ el_free(re);
} else {
rv = 0;
}
Index: src/lib/libedit/hist.c
diff -u src/lib/libedit/hist.c:1.18 src/lib/libedit/hist.c:1.19
--- src/lib/libedit/hist.c:1.18 Wed Jul 27 20:43:12 2011
+++ src/lib/libedit/hist.c Thu Jul 28 16:50:55 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: hist.c,v 1.18 2011/07/28 00:43:12 christos Exp $ */
+/* $NetBSD: hist.c,v 1.19 2011/07/28 20:50:55 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)hist.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: hist.c,v 1.18 2011/07/28 00:43:12 christos Exp $");
+__RCSID("$NetBSD: hist.c,v 1.19 2011/07/28 20:50:55 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -72,7 +72,7 @@
hist_end(EditLine *el)
{
- el_free((ptr_t) el->el_history.buf);
+ el_free(el->el_history.buf);
el->el_history.buf = NULL;
}
@@ -81,7 +81,7 @@
* Set new history interface
*/
protected int
-hist_set(EditLine *el, hist_fun_t fun, ptr_t ptr)
+hist_set(EditLine *el, hist_fun_t fun, void *ptr)
{
el->el_history.ref = ptr;
@@ -212,7 +212,7 @@
#ifdef WIDECHAR
protected wchar_t *
-hist_convert(EditLine *el, int fn, ptr_t arg)
+hist_convert(EditLine *el, int fn, void *arg)
{
HistEventW ev;
if ((*(el)->el_history.fun)((el)->el_history.ref, &ev, fn, arg) == -1)
Index: src/lib/libedit/tokenizer.c
diff -u src/lib/libedit/tokenizer.c:1.18 src/lib/libedit/tokenizer.c:1.19
--- src/lib/libedit/tokenizer.c:1.18 Sun Jan 3 13:27:10 2010
+++ src/lib/libedit/tokenizer.c Thu Jul 28 16:50:55 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: tokenizer.c,v 1.18 2010/01/03 18:27:10 christos Exp $ */
+/* $NetBSD: tokenizer.c,v 1.19 2011/07/28 20:50:55 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)tokenizer.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: tokenizer.c,v 1.18 2010/01/03 18:27:10 christos Exp $");
+__RCSID("$NetBSD: tokenizer.c,v 1.19 2011/07/28 20:50:55 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -106,29 +106,29 @@
public TYPE(Tokenizer) *
FUN(tok,init)(const Char *ifs)
{
- TYPE(Tokenizer) *tok = tok_malloc(sizeof(TYPE(Tokenizer)));
+ TYPE(Tokenizer) *tok = tok_malloc(sizeof(*tok));
if (tok == NULL)
return NULL;
tok->ifs = tok_strdup(ifs ? ifs : IFS);
if (tok->ifs == NULL) {
- tok_free((ptr_t)tok);
+ tok_free(tok);
return NULL;
}
tok->argc = 0;
tok->amax = AINCR;
tok->argv = tok_malloc(sizeof(*tok->argv) * tok->amax);
if (tok->argv == NULL) {
- tok_free((ptr_t)tok->ifs);
- tok_free((ptr_t)tok);
+ tok_free(tok->ifs);
+ tok_free(tok);
return NULL;
}
tok->argv[0] = NULL;
tok->wspace = tok_malloc(WINCR * sizeof(*tok->wspace));
if (tok->wspace == NULL) {
- tok_free((ptr_t)tok->argv);
- tok_free((ptr_t)tok->ifs);
- tok_free((ptr_t)tok);
+ tok_free(tok->argv);
+ tok_free(tok->ifs);
+ tok_free(tok);
return NULL;
}
tok->wmax = tok->wspace + WINCR;
@@ -163,10 +163,10 @@
FUN(tok,end)(TYPE(Tokenizer) *tok)
{
- tok_free((ptr_t) tok->ifs);
- tok_free((ptr_t) tok->wspace);
- tok_free((ptr_t) tok->argv);
- tok_free((ptr_t) tok);
+ tok_free(tok->ifs);
+ tok_free(tok->wspace);
+ tok_free(tok->argv);
+ tok_free(tok);
}
Index: src/lib/libedit/hist.h
diff -u src/lib/libedit/hist.h:1.12 src/lib/libedit/hist.h:1.13
--- src/lib/libedit/hist.h:1.12 Wed Dec 30 18:54:52 2009
+++ src/lib/libedit/hist.h Thu Jul 28 16:50:55 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: hist.h,v 1.12 2009/12/30 23:54:52 christos Exp $ */
+/* $NetBSD: hist.h,v 1.13 2011/07/28 20:50:55 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -42,14 +42,14 @@
#include "histedit.h"
-typedef int (*hist_fun_t)(ptr_t, TYPE(HistEvent) *, int, ...);
+typedef int (*hist_fun_t)(void *, TYPE(HistEvent) *, int, ...);
typedef struct el_history_t {
Char *buf; /* The history buffer */
size_t sz; /* Size of history buffer */
Char *last; /* The last character */
int eventno; /* Event we are looking for */
- ptr_t ref; /* Argument for history fcns */
+ void * ref; /* Argument for history fcns */
hist_fun_t fun; /* Event access */
TYPE(HistEvent) ev; /* Event cookie */
} el_history_t;
@@ -77,11 +77,11 @@
protected int hist_init(EditLine *);
protected void hist_end(EditLine *);
protected el_action_t hist_get(EditLine *);
-protected int hist_set(EditLine *, hist_fun_t, ptr_t);
+protected int hist_set(EditLine *, hist_fun_t, void *);
protected int hist_command(EditLine *, int, const Char **);
protected int hist_enlargebuf(EditLine *, size_t, size_t);
#ifdef WIDECHAR
-protected wchar_t *hist_convert(EditLine *, int, ptr_t);
+protected wchar_t *hist_convert(EditLine *, int, void *);
#endif
#endif /* _h_el_hist */
Index: src/lib/libedit/histedit.h
diff -u src/lib/libedit/histedit.h:1.47 src/lib/libedit/histedit.h:1.48
--- src/lib/libedit/histedit.h:1.47 Sat Aug 28 11:44:59 2010
+++ src/lib/libedit/histedit.h Thu Jul 28 16:50:55 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: histedit.h,v 1.47 2010/08/28 15:44:59 christos Exp $ */
+/* $NetBSD: histedit.h,v 1.48 2011/07/28 20:50:55 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -142,7 +142,7 @@
#define EL_SETTY 8 /* , const Char *, ..., NULL); set */
#define EL_ADDFN 9 /* , const Char *, const Char, set */
/* el_func_t); */
-#define EL_HIST 10 /* , hist_fun_t, const ptr_t); set */
+#define EL_HIST 10 /* , hist_fun_t, const void *); set */
#define EL_EDITMODE 11 /* , int); set/get */
#define EL_RPROMPT 12 /* , prompt_func); set/get */
#define EL_GETCFN 13 /* , el_rfunc_t); set/get */
Index: src/lib/libedit/history.c
diff -u src/lib/libedit/history.c:1.41 src/lib/libedit/history.c:1.42
--- src/lib/libedit/history.c:1.41 Wed Jul 27 20:43:33 2011
+++ src/lib/libedit/history.c Thu Jul 28 16:50:55 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: history.c,v 1.41 2011/07/28 00:43:33 christos Exp $ */
+/* $NetBSD: history.c,v 1.42 2011/07/28 20:50:55 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)history.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: history.c,v 1.41 2011/07/28 00:43:33 christos Exp $");
+__RCSID("$NetBSD: history.c,v 1.42 2011/07/28 20:50:55 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -59,13 +59,13 @@
#include "histedit.h"
#include "chartype.h"
-typedef int (*history_gfun_t)(ptr_t, TYPE(HistEvent) *);
-typedef int (*history_efun_t)(ptr_t, TYPE(HistEvent) *, const Char *);
-typedef void (*history_vfun_t)(ptr_t, TYPE(HistEvent) *);
-typedef int (*history_sfun_t)(ptr_t, TYPE(HistEvent) *, const int);
+typedef int (*history_gfun_t)(void *, TYPE(HistEvent) *);
+typedef int (*history_efun_t)(void *, TYPE(HistEvent) *, const Char *);
+typedef void (*history_vfun_t)(void *, TYPE(HistEvent) *);
+typedef int (*history_sfun_t)(void *, TYPE(HistEvent) *, const int);
struct TYPE(history) {
- ptr_t h_ref; /* Argument for history fcns */
+ void *h_ref; /* Argument for history fcns */
int h_ent; /* Last entry point for history */
history_gfun_t h_first; /* Get the first element */
history_gfun_t h_next; /* Get the next element */
@@ -137,23 +137,23 @@
#define H_UNIQUE 1 /* Store only unique elements */
} history_t;
-private int history_def_next(ptr_t, TYPE(HistEvent) *);
-private int history_def_first(ptr_t, TYPE(HistEvent) *);
-private int history_def_prev(ptr_t, TYPE(HistEvent) *);
-private int history_def_last(ptr_t, TYPE(HistEvent) *);
-private int history_def_curr(ptr_t, TYPE(HistEvent) *);
-private int history_def_set(ptr_t, TYPE(HistEvent) *, const int);
-private void history_def_clear(ptr_t, TYPE(HistEvent) *);
-private int history_def_enter(ptr_t, TYPE(HistEvent) *, const Char *);
-private int history_def_add(ptr_t, TYPE(HistEvent) *, const Char *);
-private int history_def_del(ptr_t, TYPE(HistEvent) *, const int);
+private int history_def_next(void *, TYPE(HistEvent) *);
+private int history_def_first(void *, TYPE(HistEvent) *);
+private int history_def_prev(void *, TYPE(HistEvent) *);
+private int history_def_last(void *, TYPE(HistEvent) *);
+private int history_def_curr(void *, TYPE(HistEvent) *);
+private int history_def_set(void *, TYPE(HistEvent) *, const int);
+private void history_def_clear(void *, TYPE(HistEvent) *);
+private int history_def_enter(void *, TYPE(HistEvent) *, const Char *);
+private int history_def_add(void *, TYPE(HistEvent) *, const Char *);
+private int history_def_del(void *, TYPE(HistEvent) *, const int);
-private int history_def_init(ptr_t *, TYPE(HistEvent) *, int);
+private int history_def_init(void **, TYPE(HistEvent) *, int);
private int history_def_insert(history_t *, TYPE(HistEvent) *, const Char *);
private void history_def_delete(history_t *, TYPE(HistEvent) *, hentry_t *);
private int history_deldata_nth(history_t *, TYPE(HistEvent) *, int, void **);
-private int history_set_nth(ptr_t, TYPE(HistEvent) *, int);
+private int history_set_nth(void *, TYPE(HistEvent) *, int);
#define history_def_setsize(p, num)(void) (((history_t *)p)->max = (num))
#define history_def_getsize(p) (((history_t *)p)->cur)
@@ -211,7 +211,7 @@
* Default function to return the first event in the history.
*/
private int
-history_def_first(ptr_t p, TYPE(HistEvent) *ev)
+history_def_first(void *p, TYPE(HistEvent) *ev)
{
history_t *h = (history_t *) p;
@@ -231,7 +231,7 @@
* Default function to return the last event in the history.
*/
private int
-history_def_last(ptr_t p, TYPE(HistEvent) *ev)
+history_def_last(void *p, TYPE(HistEvent) *ev)
{
history_t *h = (history_t *) p;
@@ -251,7 +251,7 @@
* Default function to return the next event in the history.
*/
private int
-history_def_next(ptr_t p, TYPE(HistEvent) *ev)
+history_def_next(void *p, TYPE(HistEvent) *ev)
{
history_t *h = (history_t *) p;
@@ -276,7 +276,7 @@
* Default function to return the previous event in the history.
*/
private int
-history_def_prev(ptr_t p, TYPE(HistEvent) *ev)
+history_def_prev(void *p, TYPE(HistEvent) *ev)
{
history_t *h = (history_t *) p;
@@ -302,7 +302,7 @@
* Default function to return the current event in the history.
*/
private int
-history_def_curr(ptr_t p, TYPE(HistEvent) *ev)
+history_def_curr(void *p, TYPE(HistEvent) *ev)
{
history_t *h = (history_t *) p;
@@ -323,7 +323,7 @@
* given one.
*/
private int
-history_def_set(ptr_t p, TYPE(HistEvent) *ev, const int n)
+history_def_set(void *p, TYPE(HistEvent) *ev, const int n)
{
history_t *h = (history_t *) p;
@@ -350,7 +350,7 @@
* n-th one.
*/
private int
-history_set_nth(ptr_t p, TYPE(HistEvent) *ev, int n)
+history_set_nth(void *p, TYPE(HistEvent) *ev, int n)
{
history_t *h = (history_t *) p;
@@ -374,7 +374,7 @@
* Append string to element
*/
private int
-history_def_add(ptr_t p, TYPE(HistEvent) *ev, const Char *str)
+history_def_add(void *p, TYPE(HistEvent) *ev, const Char *str)
{
history_t *h = (history_t *) p;
size_t len;
@@ -392,7 +392,7 @@
(void) Strncpy(s, h->cursor->ev.str, len);
s[len - 1] = '\0';
(void) Strncat(s, str, len - Strlen(s) - 1);
- h_free((ptr_t)evp->str);
+ h_free(evp->str);
evp->str = s;
*ev = h->cursor->ev;
return (0);
@@ -422,7 +422,7 @@
*/
/* ARGSUSED */
private int
-history_def_del(ptr_t p, TYPE(HistEvent) *ev __attribute__((__unused__)),
+history_def_del(void *p, TYPE(HistEvent) *ev __attribute__((__unused__)),
const int num)
{
history_t *h = (history_t *) p;
@@ -453,7 +453,7 @@
}
hp->prev->next = hp->next;
hp->next->prev = hp->prev;
- h_free((ptr_t) evp->str);
+ h_free(evp->str);
h_free(hp);
h->cur--;
}
@@ -471,7 +471,7 @@
if (c == NULL)
goto oomem;
if ((c->ev.str = h_strdup(str)) == NULL) {
- h_free((ptr_t)c);
+ h_free(c);
goto oomem;
}
c->data = NULL;
@@ -495,7 +495,7 @@
* Default function to enter an item in the history
*/
private int
-history_def_enter(ptr_t p, TYPE(HistEvent) *ev, const Char *str)
+history_def_enter(void *p, TYPE(HistEvent) *ev, const Char *str)
{
history_t *h = (history_t *) p;
@@ -522,9 +522,9 @@
*/
/* ARGSUSED */
private int
-history_def_init(ptr_t *p, TYPE(HistEvent) *ev __attribute__((__unused__)), int n)
+history_def_init(void **p, TYPE(HistEvent) *ev __attribute__((__unused__)), int n)
{
- history_t *h = (history_t *) h_malloc(sizeof(history_t));
+ history_t *h = (history_t *) h_malloc(sizeof(*h));
if (h == NULL)
return -1;
@@ -538,7 +538,7 @@
h->list.ev.num = 0;
h->cursor = &h->list;
h->flags = 0;
- *p = (ptr_t) h;
+ *p = h;
return 0;
}
@@ -547,7 +547,7 @@
* Default history cleanup function
*/
private void
-history_def_clear(ptr_t p, TYPE(HistEvent) *ev)
+history_def_clear(void *p, TYPE(HistEvent) *ev)
{
history_t *h = (history_t *) p;
@@ -570,12 +570,12 @@
FUN(history,init)(void)
{
TYPE(HistEvent) ev;
- TYPE(History) *h = (TYPE(History) *) h_malloc(sizeof(TYPE(History)));
+ TYPE(History) *h = (TYPE(History) *) h_malloc(sizeof(*h));
if (h == NULL)
return NULL;
if (history_def_init(&h->h_ref, &ev, 0) == -1) {
- h_free((ptr_t)h);
+ h_free(h);
return NULL;
}
h->h_ent = -1;
@@ -751,7 +751,7 @@
if (strncmp(line, hist_cookie, sz) != 0)
goto done;
- ptr = h_malloc(max_size = 1024);
+ ptr = h_malloc((max_size = 1024) * sizeof(*ptr));
if (ptr == NULL)
goto done;
for (i = 0; (line = fgetln(fp, &sz)) != NULL; i++) {
@@ -765,7 +765,7 @@
if (max_size < sz) {
char *nptr;
max_size = (sz + 1024) & ~1023;
- nptr = h_realloc(ptr, max_size);
+ nptr = h_realloc(ptr, max_size * sizeof(*ptr));
if (nptr == NULL) {
i = -1;
goto oomem;
@@ -780,7 +780,7 @@
}
}
oomem:
- h_free((ptr_t)ptr);
+ h_free(ptr);
done:
(void) fclose(fp);
return (i);
@@ -810,7 +810,7 @@
goto done;
if (fputs(hist_cookie, fp) == EOF)
goto done;
- ptr = h_malloc(max_size = 1024);
+ ptr = h_malloc((max_size = 1024) * sizeof(*ptr));
if (ptr == NULL)
goto done;
for (i = 0, retval = HLAST(h, &ev);
@@ -821,7 +821,7 @@
if (len >= max_size) {
char *nptr;
max_size = (len + 1024) & ~1023;
- nptr = h_realloc(ptr, max_size);
+ nptr = h_realloc(ptr, max_size * sizeof(*ptr));
if (nptr == NULL) {
i = -1;
goto oomem;
@@ -832,7 +832,7 @@
(void) fprintf(fp, "%s\n", ptr);
}
oomem:
- h_free((ptr_t)ptr);
+ h_free(ptr);
done:
(void) fclose(fp);
return (i);
@@ -1039,7 +1039,7 @@
{
TYPE(History) hf;
- hf.h_ref = va_arg(va, ptr_t);
+ hf.h_ref = va_arg(va, void *);
h->h_ent = -1;
hf.h_first = va_arg(va, history_gfun_t);
hf.h_next = va_arg(va, history_gfun_t);
Index: src/lib/libedit/keymacro.c
diff -u src/lib/libedit/keymacro.c:1.3 src/lib/libedit/keymacro.c:1.4
--- src/lib/libedit/keymacro.c:1.3 Wed Jul 27 23:52:19 2011
+++ src/lib/libedit/keymacro.c Thu Jul 28 16:50:55 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: keymacro.c,v 1.3 2011/07/28 03:52:19 christos Exp $ */
+/* $NetBSD: keymacro.c,v 1.4 2011/07/28 20:50:55 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)key.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: keymacro.c,v 1.3 2011/07/28 03:52:19 christos Exp $");
+__RCSID("$NetBSD: keymacro.c,v 1.4 2011/07/28 20:50:55 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -120,7 +120,7 @@
keymacro_end(EditLine *el)
{
- el_free((ptr_t) el->el_keymacro.buf);
+ el_free(el->el_keymacro.buf);
el->el_keymacro.buf = NULL;
node__free(el->el_keymacro.map);
}
@@ -343,7 +343,7 @@
case XK_STR:
case XK_EXE:
if (ptr->val.str)
- el_free((ptr_t) ptr->val.str);
+ el_free(ptr->val.str);
break;
default:
EL_ABORT((el->el_errfile, "Bad XK_ type %d\n",
@@ -444,13 +444,13 @@
case XK_EXE:
case XK_STR:
if (ptr->val.str != NULL)
- el_free((ptr_t) ptr->val.str);
+ el_free(ptr->val.str);
break;
default:
EL_ABORT((el->el_errfile, "Bad XK_ type %d\n", ptr->type));
break;
}
- el_free((ptr_t) ptr);
+ el_free(ptr);
}
@@ -462,7 +462,7 @@
{
keymacro_node_t *ptr;
- ptr = (keymacro_node_t *) el_malloc((size_t) sizeof(keymacro_node_t));
+ ptr = el_malloc(sizeof(*ptr));
if (ptr == NULL)
return NULL;
ptr->ch = ch;
@@ -480,7 +480,7 @@
return;
node__free(k->sibling);
node__free(k->next);
- el_free((ptr_t) k);
+ el_free(k);
}
/* node_lookup():
Index: src/lib/libedit/terminal.c
diff -u src/lib/libedit/terminal.c:1.3 src/lib/libedit/terminal.c:1.4
--- src/lib/libedit/terminal.c:1.3 Wed Jul 27 23:52:19 2011
+++ src/lib/libedit/terminal.c Thu Jul 28 16:50:55 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: terminal.c,v 1.3 2011/07/28 03:52:19 christos Exp $ */
+/* $NetBSD: terminal.c,v 1.4 2011/07/28 20:50:55 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)term.c 8.2 (Berkeley) 4/30/95";
#else
-__RCSID("$NetBSD: terminal.c,v 1.3 2011/07/28 03:52:19 christos Exp $");
+__RCSID("$NetBSD: terminal.c,v 1.4 2011/07/28 20:50:55 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -339,25 +339,31 @@
terminal_init(EditLine *el)
{
- el->el_terminal.t_buf = (char *) el_malloc(TC_BUFSIZE);
+ el->el_terminal.t_buf = el_malloc(TC_BUFSIZE *
+ sizeof(*el->el_terminal.t_buf));
if (el->el_terminal.t_buf == NULL)
return (-1);
- el->el_terminal.t_cap = (char *) el_malloc(TC_BUFSIZE);
+ el->el_terminal.t_cap = el_malloc(TC_BUFSIZE *
+ sizeof(*el->el_terminal.t_cap));
if (el->el_terminal.t_cap == NULL)
return (-1);
- el->el_terminal.t_fkey = (funckey_t *) el_malloc(A_K_NKEYS *
- sizeof(funckey_t));
+ el->el_terminal.t_fkey = el_malloc(A_K_NKEYS *
+ sizeof(*el->el_terminal.t_fkey));
if (el->el_terminal.t_fkey == NULL)
return (-1);
el->el_terminal.t_loc = 0;
- el->el_terminal.t_str = (char **) el_malloc(T_str * sizeof(char *));
+ el->el_terminal.t_str = el_malloc(T_str *
+ sizeof(*el->el_terminal.t_str));
if (el->el_terminal.t_str == NULL)
return (-1);
- (void) memset(el->el_terminal.t_str, 0, T_str * sizeof(char *));
- el->el_terminal.t_val = (int *) el_malloc(T_val * sizeof(int));
+ (void) memset(el->el_terminal.t_str, 0, T_str *
+ sizeof(*el->el_terminal.t_str));
+ el->el_terminal.t_val = el_malloc(T_val *
+ sizeof(*el->el_terminal.t_val));
if (el->el_terminal.t_val == NULL)
return (-1);
- (void) memset(el->el_terminal.t_val, 0, T_val * sizeof(int));
+ (void) memset(el->el_terminal.t_val, 0, T_val *
+ sizeof(*el->el_terminal.t_val));
(void) terminal_set(el, NULL);
terminal_init_arrow(el);
return (0);
@@ -370,16 +376,16 @@
terminal_end(EditLine *el)
{
- el_free((ptr_t) el->el_terminal.t_buf);
+ el_free(el->el_terminal.t_buf);
el->el_terminal.t_buf = NULL;
- el_free((ptr_t) el->el_terminal.t_cap);
+ el_free(el->el_terminal.t_cap);
el->el_terminal.t_cap = NULL;
el->el_terminal.t_loc = 0;
- el_free((ptr_t) el->el_terminal.t_str);
+ el_free(el->el_terminal.t_str);
el->el_terminal.t_str = NULL;
- el_free((ptr_t) el->el_terminal.t_val);
+ el_free(el->el_terminal.t_val);
el->el_terminal.t_val = NULL;
- el_free((ptr_t) el->el_terminal.t_fkey);
+ el_free(el->el_terminal.t_fkey);
el->el_terminal.t_fkey = NULL;
terminal_free_display(el);
}
@@ -486,8 +492,8 @@
b[i] = el_malloc(sizeof(**b) * (c->h + 1));
if (b[i] == NULL) {
while (--i >= 0)
- el_free((ptr_t) b[i]);
- el_free((ptr_t) b);
+ el_free(b[i]);
+ el_free(b);
return (-1);
}
}
@@ -501,8 +507,8 @@
b[i] = el_malloc(sizeof(**b) * (c->h + 1));
if (b[i] == NULL) {
while (--i >= 0)
- el_free((ptr_t) b[i]);
- el_free((ptr_t) b);
+ el_free(b[i]);
+ el_free(b);
return (-1);
}
}
@@ -525,15 +531,15 @@
el->el_display = NULL;
if (b != NULL) {
for (bufp = b; *bufp != NULL; bufp++)
- el_free((ptr_t) *bufp);
- el_free((ptr_t) b);
+ el_free(*bufp);
+ el_free(b);
}
b = el->el_vdisplay;
el->el_vdisplay = NULL;
if (b != NULL) {
for (bufp = b; *bufp != NULL; bufp++)
- el_free((ptr_t) *bufp);
- el_free((ptr_t) b);
+ el_free(*bufp);
+ el_free(b);
}
}
@@ -1029,7 +1035,7 @@
#ifdef TIOCGWINSZ
{
struct winsize ws;
- if (ioctl(el->el_infd, TIOCGWINSZ, (ioctl_t) & ws) != -1) {
+ if (ioctl(el->el_infd, TIOCGWINSZ, &ws) != -1) {
if (ws.ws_col)
*cols = ws.ws_col;
if (ws.ws_row)
@@ -1040,7 +1046,7 @@
#ifdef TIOCGSIZE
{
struct ttysize ts;
- if (ioctl(el->el_infd, TIOCGSIZE, (ioctl_t) & ts) != -1) {
+ if (ioctl(el->el_infd, TIOCGSIZE, &ts) != -1) {
if (ts.ts_cols)
*cols = ts.ts_cols;
if (ts.ts_lines)
Index: src/lib/libedit/map.c
diff -u src/lib/libedit/map.c:1.27 src/lib/libedit/map.c:1.28
--- src/lib/libedit/map.c:1.27 Wed Jul 27 21:56:27 2011
+++ src/lib/libedit/map.c Thu Jul 28 16:50:55 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: map.c,v 1.27 2011/07/28 01:56:27 christos Exp $ */
+/* $NetBSD: map.c,v 1.28 2011/07/28 20:50:55 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)map.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: map.c,v 1.27 2011/07/28 01:56:27 christos Exp $");
+__RCSID("$NetBSD: map.c,v 1.28 2011/07/28 20:50:55 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -903,26 +903,25 @@
EL_ABORT((el->errfile, "Vi insert map incorrect\n"));
#endif
- el->el_map.alt = (el_action_t *)el_malloc(sizeof(el_action_t) * N_KEYS);
+ el->el_map.alt = el_malloc(sizeof(*el->el_map.alt) * N_KEYS);
if (el->el_map.alt == NULL)
return (-1);
- el->el_map.key = (el_action_t *)el_malloc(sizeof(el_action_t) * N_KEYS);
+ el->el_map.key = el_malloc(sizeof(*el->el_map.key) * N_KEYS);
if (el->el_map.key == NULL)
return (-1);
el->el_map.emacs = el_map_emacs;
el->el_map.vic = el_map_vi_command;
el->el_map.vii = el_map_vi_insert;
- el->el_map.help = (el_bindings_t *) el_malloc(sizeof(el_bindings_t) *
- EL_NUM_FCNS);
+ el->el_map.help = el_malloc(sizeof(*el->el_map.help) * EL_NUM_FCNS);
if (el->el_map.help == NULL)
return (-1);
(void) memcpy(el->el_map.help, help__get(),
- sizeof(el_bindings_t) * EL_NUM_FCNS);
- el->el_map.func = (el_func_t *)el_malloc(sizeof(el_func_t) *
- EL_NUM_FCNS);
+ sizeof(*el->el_map.help) * EL_NUM_FCNS);
+ el->el_map.func = el_malloc(sizeof(*el->el_map.func) * EL_NUM_FCNS);
if (el->el_map.func == NULL)
return (-1);
- memcpy(el->el_map.func, func__get(), sizeof(el_func_t) * EL_NUM_FCNS);
+ memcpy(el->el_map.func, func__get(), sizeof(*el->el_map.func)
+ * EL_NUM_FCNS);
el->el_map.nfunc = EL_NUM_FCNS;
#ifdef VIDEFAULT
@@ -941,16 +940,16 @@
map_end(EditLine *el)
{
- el_free((ptr_t) el->el_map.alt);
+ el_free(el->el_map.alt);
el->el_map.alt = NULL;
- el_free((ptr_t) el->el_map.key);
+ el_free(el->el_map.key);
el->el_map.key = NULL;
el->el_map.emacs = NULL;
el->el_map.vic = NULL;
el->el_map.vii = NULL;
- el_free((ptr_t) el->el_map.help);
+ el_free(el->el_map.help);
el->el_map.help = NULL;
- el_free((ptr_t) el->el_map.func);
+ el_free(el->el_map.func);
el->el_map.func = NULL;
}
@@ -1401,13 +1400,14 @@
if (name == NULL || help == NULL || func == NULL)
return (-1);
- if ((p = el_realloc(el->el_map.func, nf * sizeof(el_func_t))) == NULL)
+ if ((p = el_realloc(el->el_map.func, nf *
+ sizeof(*el->el_map.func))) == NULL)
return (-1);
- el->el_map.func = (el_func_t *) p;
- if ((p = el_realloc(el->el_map.help, nf * sizeof(el_bindings_t)))
+ el->el_map.func = p;
+ if ((p = el_realloc(el->el_map.help, nf * sizeof(*el->el_map.help)))
== NULL)
return (-1);
- el->el_map.help = (el_bindings_t *) p;
+ el->el_map.help = p;
nf = el->el_map.nfunc;
el->el_map.func[nf] = func;
Index: src/lib/libedit/read.c
diff -u src/lib/libedit/read.c:1.63 src/lib/libedit/read.c:1.64
--- src/lib/libedit/read.c:1.63 Wed Jul 27 21:56:27 2011
+++ src/lib/libedit/read.c Thu Jul 28 16:50:55 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: read.c,v 1.63 2011/07/28 01:56:27 christos Exp $ */
+/* $NetBSD: read.c,v 1.64 2011/07/28 20:50:55 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)read.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: read.c,v 1.63 2011/07/28 01:56:27 christos Exp $");
+__RCSID("$NetBSD: read.c,v 1.64 2011/07/28 20:50:55 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -162,7 +162,7 @@
{
int zero = 0;
- if (ioctl(fd, FIONBIO, (ioctl_t) & zero) == -1)
+ if (ioctl(fd, FIONBIO, &zero) == -1)
return (-1);
else
e = 1;
@@ -196,7 +196,7 @@
/* FIONREAD attempts to buffer up multiple bytes, and to make that work
* properly with partial wide/UTF-8 characters would need some careful work. */
#ifdef FIONREAD
- (void) ioctl(el->el_infd, FIONREAD, (ioctl_t) & chrs);
+ (void) ioctl(el->el_infd, FIONREAD, &chrs);
if (chrs > 0) {
char buf[EL_BUFSIZ];
@@ -516,7 +516,7 @@
if (el->el_tty.t_mode == EX_IO && ma->level < 0) {
long chrs = 0;
- (void) ioctl(el->el_infd, FIONREAD, (ioctl_t) & chrs);
+ (void) ioctl(el->el_infd, FIONREAD, &chrs);
if (chrs == 0) {
if (tty_rawmode(el) < 0) {
errno = 0;
Index: src/lib/libedit/readline.c
diff -u src/lib/libedit/readline.c:1.94 src/lib/libedit/readline.c:1.95
--- src/lib/libedit/readline.c:1.94 Thu Jul 28 13:33:39 2011
+++ src/lib/libedit/readline.c Thu Jul 28 16:50:55 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: readline.c,v 1.94 2011/07/28 17:33:39 christos Exp $ */
+/* $NetBSD: readline.c,v 1.95 2011/07/28 20:50:55 christos Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
#include "config.h"
#if !defined(lint) && !defined(SCCSID)
-__RCSID("$NetBSD: readline.c,v 1.94 2011/07/28 17:33:39 christos Exp $");
+__RCSID("$NetBSD: readline.c,v 1.95 2011/07/28 20:50:55 christos Exp $");
#endif /* not lint && not SCCSID */
#include <sys/types.h>
@@ -261,7 +261,7 @@
if (rl_prompt != NULL && strcmp(rl_prompt, prompt) == 0)
return 0;
if (rl_prompt)
- free(rl_prompt);
+ el_free(rl_prompt);
rl_prompt = strdup(prompt);
if (rl_prompt == NULL)
return -1;
@@ -475,7 +475,7 @@
} else
s++;
}
- r = result = malloc(len + 1);
+ r = result = el_malloc((len + 1) * sizeof(*r));
if (result == NULL)
return NULL;
s = str;
@@ -565,7 +565,7 @@
else if (len == 0)
return(NULL);
else {
- if ((pat = malloc(len + 1)) == NULL)
+ if ((pat = el_malloc((len + 1) * sizeof(*pat))) == NULL)
return NULL;
(void)strncpy(pat, cmd + begin, len);
pat[len] = '\0';
@@ -573,7 +573,7 @@
if (history(h, &ev, H_CURR) != 0) {
if (pat != last_search_pat)
- free(pat);
+ el_free(pat);
return (NULL);
}
num = ev.num;
@@ -581,7 +581,7 @@
if (sub) {
if (pat != last_search_pat) {
if (last_search_pat)
- free(last_search_pat);
+ el_free(last_search_pat);
last_search_pat = pat;
}
ret = history_search(pat, -1);
@@ -593,18 +593,18 @@
history(h, &ev, H_FIRST);
(void)fprintf(rl_outstream, "%s: Event not found\n", pat);
if (pat != last_search_pat)
- free(pat);
+ el_free(pat);
return(NULL);
}
if (sub && len) {
if (last_search_match && last_search_match != pat)
- free(last_search_match);
+ el_free(last_search_match);
last_search_match = pat;
}
if (pat != last_search_pat)
- free(pat);
+ el_free(pat);
if (history(h, &ev, H_CURR) != 0)
return(NULL);
@@ -659,7 +659,8 @@
} else {
if (command[offs + 1] == '#') {
/* use command so far */
- if ((aptr = malloc(offs + 1)) == NULL)
+ if ((aptr = el_malloc((offs + 1) * sizeof(*aptr)))
+ == NULL)
return -1;
(void)strncpy(aptr, command, offs);
aptr[offs] = '\0';
@@ -679,7 +680,7 @@
if (!has_mods) {
*result = strdup(aptr ? aptr : ptr);
if (aptr)
- free(aptr);
+ el_free(aptr);
if (*result == NULL)
return -1;
return(1);
@@ -727,14 +728,14 @@
(void)fprintf(rl_outstream, "%s: Bad word specifier",
command + offs + idx);
if (aptr)
- free(aptr);
+ el_free(aptr);
return(-1);
}
} else
tmp = strdup(aptr? aptr:ptr);
if (aptr)
- free(aptr);
+ el_free(aptr);
if (*cmd == '\0' || ((size_t)(cmd - (command + offs)) >= cmdlen)) {
*result = tmp;
@@ -750,7 +751,7 @@
} else if (*cmd == 't') { /* remove leading path */
if ((aptr = strrchr(tmp, '/')) != NULL) {
aptr = strdup(aptr + 1);
- free(tmp);
+ el_free(tmp);
tmp = aptr;
}
} else if (*cmd == 'r') { /* remove trailing suffix */
@@ -759,7 +760,7 @@
} else if (*cmd == 'e') { /* remove all but suffix */
if ((aptr = strrchr(tmp, '.')) != NULL) {
aptr = strdup(aptr);
- free(tmp);
+ el_free(tmp);
tmp = aptr;
}
} else if (*cmd == 'p') /* print only */
@@ -776,10 +777,10 @@
else if (*cmd == 's') {
delim = *(++cmd), cmd++;
size = 16;
- what = realloc(from, size);
+ what = el_realloc(from, size * sizeof(*what));
if (what == NULL) {
- free(from);
- free(tmp);
+ el_free(from);
+ el_free(tmp);
return 0;
}
len = 0;
@@ -788,11 +789,12 @@
cmd++;
if (len >= size) {
char *nwhat;
- nwhat = realloc(what,
- (size <<= 1));
+ nwhat = el_realloc(what,
+ (size <<= 1) *
+ sizeof(*nwhat));
if (nwhat == NULL) {
- free(what);
- free(tmp);
+ el_free(what);
+ el_free(tmp);
return 0;
}
what = nwhat;
@@ -802,16 +804,16 @@
what[len] = '\0';
from = what;
if (*what == '\0') {
- free(what);
+ el_free(what);
if (search) {
from = strdup(search);
if (from == NULL) {
- free(tmp);
+ el_free(tmp);
return 0;
}
} else {
from = NULL;
- free(tmp);
+ el_free(tmp);
return (-1);
}
}
@@ -820,10 +822,10 @@
continue;
size = 16;
- with = realloc(to, size);
+ with = el_realloc(to, size * sizeof(*with));
if (with == NULL) {
- free(to);
- free(tmp);
+ el_free(to);
+ el_free(tmp);
return -1;
}
len = 0;
@@ -832,10 +834,11 @@
if (len + from_len + 1 >= size) {
char *nwith;
size += from_len + 1;
- nwith = realloc(with, size);
+ nwith = el_realloc(with,
+ size * sizeof(*nwith));
if (nwith == NULL) {
- free(with);
- free(tmp);
+ el_free(with);
+ el_free(tmp);
return -1;
}
with = nwith;
@@ -858,7 +861,7 @@
aptr = _rl_compat_sub(tmp, from, to, g_on);
if (aptr) {
- free(tmp);
+ el_free(tmp);
tmp = aptr;
}
g_on = 0;
@@ -890,7 +893,7 @@
*output = NULL;
if (str[0] == history_subst_char) {
/* ^foo^foo2^ is equivalent to !!:s^foo^foo2^ */
- *output = malloc(strlen(str) + 4 + 1);
+ *output = el_malloc((strlen(str) + 4 + 1) * sizeof(*output));
if (*output == NULL)
return 0;
(*output)[0] = (*output)[1] = history_expansion_char;
@@ -907,11 +910,12 @@
#define ADD_STRING(what, len, fr) \
{ \
if (idx + len + 1 > size) { \
- char *nresult = realloc(result, (size += len + 1));\
+ char *nresult = el_realloc(result, \
+ (size += len + 1) * sizeof(*nresult)); \
if (nresult == NULL) { \
- free(*output); \
+ el_free(*output); \
if (/*CONSTCOND*/fr) \
- free(tmp); \
+ el_free(tmp); \
return 0; \
} \
result = nresult; \
@@ -978,7 +982,7 @@
ADD_STRING(tmp, len, 1);
}
if (tmp) {
- free(tmp);
+ el_free(tmp);
tmp = NULL;
}
i = j;
@@ -995,7 +999,7 @@
ret = -1;
#endif
}
- free(*output);
+ el_free(*output);
*output = result;
return (ret);
@@ -1036,7 +1040,7 @@
for (i = start, len = 0; i <= (size_t)end; i++)
len += strlen(arr[i]) + 1;
len++;
- result = malloc(len);
+ result = el_malloc(len * sizeof(*result));
if (result == NULL)
goto out;
@@ -1050,8 +1054,8 @@
out:
for (i = 0; arr[i]; i++)
- free(arr[i]);
- free(arr);
+ el_free(arr[i]);
+ el_free(arr);
return result;
}
@@ -1090,19 +1094,19 @@
if (idx + 2 >= size) {
char **nresult;
size <<= 1;
- nresult = realloc(result, size * sizeof(char *));
+ nresult = el_realloc(result, size * sizeof(*nresult));
if (nresult == NULL) {
- free(result);
+ el_free(result);
return NULL;
}
result = nresult;
}
len = i - start;
- temp = malloc(len + 1);
+ temp = el_malloc((len + 1) * sizeof(*temp));
if (temp == NULL) {
for (i = 0; i < idx; i++)
- free(result[i]);
- free(result);
+ el_free(result[i]);
+ el_free(result);
return NULL;
}
(void)strncpy(temp, &str[start], len);
@@ -1395,11 +1399,11 @@
if (h == NULL || e == NULL)
rl_initialize();
- if ((he = malloc(sizeof(*he))) == NULL)
+ if ((he = el_malloc(sizeof(*he))) == NULL)
return NULL;
if (history(h, &ev, H_DELDATA, num, &he->data) != 0) {
- free(he);
+ el_free(he);
return NULL;
}
@@ -1433,7 +1437,7 @@
if (history(h, &ev, H_LAST) != 0)
return NULL; /* error */
- if ((he = malloc(sizeof(*he))) == NULL)
+ if ((he = el_malloc(sizeof(*he))) == NULL)
return NULL;
/* look forwards for event matching specified offset */
@@ -1453,7 +1457,7 @@
return he;
out:
- free(he);
+ el_free(he);
return NULL;
}
@@ -2117,7 +2121,7 @@
len = 1;
max = 10;
- if ((list = malloc(max * sizeof(*list))) == NULL)
+ if ((list = el_malloc(max * sizeof(*list))) == NULL)
return NULL;
while ((match = (*fun)(str, (int)(len - 1))) != NULL) {
@@ -2125,7 +2129,7 @@
if (len == max) {
char **nl;
max += 10;
- if ((nl = realloc(list, max * sizeof(*nl))) == NULL)
+ if ((nl = el_realloc(list, max * sizeof(*nl))) == NULL)
goto out;
list = nl;
}
@@ -2152,7 +2156,7 @@
if ((list[0] = strdup(str)) == NULL)
goto out;
} else {
- if ((list[0] = malloc(min + 1)) == NULL)
+ if ((list[0] = el_malloc((min + 1) * sizeof(*list[0]))) == NULL)
goto out;
(void)memcpy(list[0], list[1], min);
list[0][min] = '\0';
@@ -2160,7 +2164,7 @@
return list;
out:
- free(list);
+ el_free(list);
return NULL;
}
@@ -2195,7 +2199,7 @@
{
HISTORY_STATE *hs;
- if ((hs = malloc(sizeof(HISTORY_STATE))) == NULL)
+ if ((hs = el_malloc(sizeof(*hs))) == NULL)
return (NULL);
hs->length = history_length;
return (hs);
Index: src/lib/libedit/sig.c
diff -u src/lib/libedit/sig.c:1.16 src/lib/libedit/sig.c:1.17
--- src/lib/libedit/sig.c:1.16 Wed Jul 27 20:46:06 2011
+++ src/lib/libedit/sig.c Thu Jul 28 16:50:55 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: sig.c,v 1.16 2011/07/28 00:46:06 christos Exp $ */
+/* $NetBSD: sig.c,v 1.17 2011/07/28 20:50:55 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)sig.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: sig.c,v 1.16 2011/07/28 00:46:06 christos Exp $");
+__RCSID("$NetBSD: sig.c,v 1.17 2011/07/28 20:50:55 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -146,7 +146,7 @@
sig_end(EditLine *el)
{
- el_free((ptr_t) el->el_signal);
+ el_free(el->el_signal);
el->el_signal = NULL;
}
Index: src/lib/libedit/sys.h
diff -u src/lib/libedit/sys.h:1.14 src/lib/libedit/sys.h:1.15
--- src/lib/libedit/sys.h:1.14 Wed Jul 27 20:45:30 2011
+++ src/lib/libedit/sys.h Thu Jul 28 16:50:55 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: sys.h,v 1.14 2011/07/28 00:45:30 christos Exp $ */
+/* $NetBSD: sys.h,v 1.15 2011/07/28 20:50:55 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -75,16 +75,6 @@
# define __arraycount(a) (sizeof(a) / sizeof(*(a)))
#endif
-#ifndef _PTR_T
-# define _PTR_T
-typedef void *ptr_t;
-#endif
-
-#ifndef _IOCTL_T
-# define _IOCTL_T
-typedef void *ioctl_t;
-#endif
-
#include <stdio.h>
#ifndef HAVE_STRLCAT
@@ -164,8 +154,8 @@
# define strerror(e) sys_errlist[e]
# endif
# ifdef SABER
-extern ptr_t memcpy(ptr_t, const ptr_t, size_t);
-extern ptr_t memset(ptr_t, int, size_t);
+extern void * memcpy(void *, const void *, size_t);
+extern void * memset(void *, int, size_t);
# endif
extern char *fgetline(FILE *, int *);
#endif
Index: src/lib/libedit/vi.c
diff -u src/lib/libedit/vi.c:1.35 src/lib/libedit/vi.c:1.36
--- src/lib/libedit/vi.c:1.35 Wed Jul 27 20:45:14 2011
+++ src/lib/libedit/vi.c Thu Jul 28 16:50:55 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: vi.c,v 1.35 2011/07/28 00:45:14 christos Exp $ */
+/* $NetBSD: vi.c,v 1.36 2011/07/28 20:50:55 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@@ -42,7 +42,7 @@
#if 0
static char sccsid[] = "@(#)vi.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: vi.c,v 1.35 2011/07/28 00:45:14 christos Exp $");
+__RCSID("$NetBSD: vi.c,v 1.36 2011/07/28 20:50:55 christos Exp $");
#endif
#endif /* not lint && not SCCSID */
@@ -1020,7 +1020,7 @@
return CC_ERROR;
len = (size_t)(el->el_line.lastchar - el->el_line.buffer);
#define TMP_BUFSIZ (EL_BUFSIZ * MB_LEN_MAX)
- cp = el_malloc(TMP_BUFSIZ);
+ cp = el_malloc(TMP_BUFSIZ * sizeof(*cp));
if (cp == NULL) {
unlink(tempfile);
close(fd);
@@ -1028,7 +1028,7 @@
}
line = el_malloc(len * sizeof(*line));
if (line == NULL) {
- el_free((ptr_t)cp);
+ el_free(cp);
return CC_ERROR;
}
Strncpy(line, el->el_line.buffer, len);