Skip to content

Commit

Permalink
Discard BCOPY/BZERO macros.
Browse files Browse the repository at this point in the history
Compiler recognizes memmove(3) and memset(3), and produces smaller
binaries.

Closes: #46
  • Loading branch information
mmcco authored and lichray committed Jan 3, 2016
1 parent 5ecc7ec commit 86294be
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 13 deletions.
6 changes: 3 additions & 3 deletions common/conv.c
Expand Up @@ -118,7 +118,7 @@ default_char2int(SCR *sp, const char * str, ssize_t len, CONVWIN *cw,
size_t left = len;
int error = 1;

BZERO(&mbs, 1);
memset(&mbs, 0, sizeof(mbs));
BINC_RETW(NULL, *tostr, *blen, nlen);

#ifdef USE_ICONV
Expand Down Expand Up @@ -245,7 +245,7 @@ default_int2char(SCR *sp, const CHAR_T * str, ssize_t len, CONVWIN *cw,
#endif


BZERO(&mbs, 1);
memset(&mbs, 0, sizeof(mbs));
BINC_RETC(NULL, *tostr, *blen, nlen);
dst = *tostr; buflen = *blen;

Expand Down Expand Up @@ -323,7 +323,7 @@ conv_init(SCR *orig, SCR *sp)
if (orig == NULL)
setlocale(LC_ALL, "");
if (orig != NULL)
BCOPY(&orig->conv, &sp->conv, 1);
memmove(&sp->conv, &orig->conv, sizeof(CONV));
#ifdef USE_WIDECHAR
else {
char *ctype = setlocale(LC_CTYPE, NULL);
Expand Down
4 changes: 2 additions & 2 deletions common/key.c
Expand Up @@ -374,8 +374,8 @@ v_event_push(SCR *sp,
if (total >= gp->i_nelem && v_event_grow(sp, MAX(total, 64)))
return (1);
if (gp->i_cnt)
BCOPY(gp->i_event + gp->i_next,
gp->i_event + TERM_PUSH_SHIFT + nitems, gp->i_cnt);
memmove(gp->i_event + TERM_PUSH_SHIFT + nitems,
gp->i_event + gp->i_next, gp->i_cnt * sizeof(EVENT));
gp->i_next = TERM_PUSH_SHIFT;

/* Put the new items into the queue. */
Expand Down
9 changes: 1 addition & 8 deletions common/mem.h
Expand Up @@ -6,7 +6,7 @@
*
* See the LICENSE file for redistribution information.
*
* $Id: mem.h,v 10.17 2012/10/07 00:40:29 zy Exp $
* $Id: mem.h,v 10.18 2016/01/03 15:47:56 zy Exp $
*/

#ifdef DEBUG
Expand Down Expand Up @@ -192,13 +192,6 @@
p = newp; \
}

/*
* Versions of bcopy(3) and bzero(3) that use the size of the
* initial pointer to figure out how much memory to manipulate.
*/
#define BCOPY(p, t, len) bcopy(p, t, (len) * sizeof(*(p)))
#define BZERO(p, len) bzero(p, (len) * sizeof(*(p)))

/*
* p2roundup --
* Get next power of 2; convenient for realloc.
Expand Down

0 comments on commit 86294be

Please sign in to comment.