From 668ce01b03bd7e81c9cae1ce22f21df2d1c0a647 Mon Sep 17 00:00:00 2001 From: kcwu Date: Fri, 17 Jan 2003 07:14:14 +0000 Subject: Use realloc. Don't malloc, memcpy, and free. git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk@618 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- pttbbs/mbbsd/board.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/pttbbs/mbbsd/board.c b/pttbbs/mbbsd/board.c index 58444c27..fa57f806 100644 --- a/pttbbs/mbbsd/board.c +++ b/pttbbs/mbbsd/board.c @@ -1,4 +1,4 @@ -/* $Id: board.c,v 1.70 2003/01/17 07:10:54 kcwu Exp $ */ +/* $Id: board.c,v 1.71 2003/01/17 07:14:14 kcwu Exp $ */ #include "bbs.h" #define BRC_STRLEN 15 /* Length of board name */ #define BRC_MAXSIZE 24576 @@ -518,7 +518,6 @@ load_boards(char *key) } brdnum = 0; if (class_bid <= 0) { - boardstat_t *tmp = NULL; nbrd = (boardstat_t *) malloc(sizeof(boardstat_t) * numboards); for (i = 0; i < numboards; i++) { if ((bptr = SHM->bsorted[type][i]) == NULL) @@ -535,10 +534,7 @@ load_boards(char *key) } if (class_bid == -1) qsort(nbrd, brdnum, sizeof(boardstat_t), cmpboardfriends); - tmp = (boardstat_t *) malloc(sizeof(boardstat_t) * brdnum); - memcpy(tmp, nbrd, sizeof(boardstat_t) * brdnum); - free(nbrd); - nbrd = tmp; + nbrd = realloc(nbrd, sizeof(boardstat_t) * brdnum); } else { nbrd = (boardstat_t *) malloc(bptr->childcount * sizeof(boardstat_t)); for (bptr = bptr->firstchild[type]; bptr != (boardheader_t *) ~ 0; -- cgit v1.2.3