summaryrefslogtreecommitdiffstats
path: root/mbbsd/announce.c
diff options
context:
space:
mode:
authorpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-07-26 00:10:18 +0800
committerpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-07-26 00:10:18 +0800
commitfe85c2da76306d6875a4bcae37c7afee3e9e6eac (patch)
tree4e93dbb3aa7b3122a895c37451b4aa53aa9ff5fc /mbbsd/announce.c
parent31a7ad7d2f3b4dcdf73844dc62f33b168c1f23ec (diff)
downloadpttbbs-fe85c2da76306d6875a4bcae37c7afee3e9e6eac.tar
pttbbs-fe85c2da76306d6875a4bcae37c7afee3e9e6eac.tar.gz
pttbbs-fe85c2da76306d6875a4bcae37c7afee3e9e6eac.tar.bz2
pttbbs-fe85c2da76306d6875a4bcae37c7afee3e9e6eac.tar.lz
pttbbs-fe85c2da76306d6875a4bcae37c7afee3e9e6eac.tar.xz
pttbbs-fe85c2da76306d6875a4bcae37c7afee3e9e6eac.tar.zst
pttbbs-fe85c2da76306d6875a4bcae37c7afee3e9e6eac.zip
- restrict fast recommendation
- release large memory buffer for CopyBuffer(announce.c) git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2961 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd/announce.c')
-rw-r--r--mbbsd/announce.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/mbbsd/announce.c b/mbbsd/announce.c
index 6d52212f..f8332c02 100644
--- a/mbbsd/announce.c
+++ b/mbbsd/announce.c
@@ -2,12 +2,18 @@
#include "bbs.h"
/* copy temp queue operation -------------------------------------- */
+
+/* TODO
+ * change this to char* instead of char[]
+ */
typedef struct {
char copyfile[PATHLEN];
char copytitle[TTLEN + 1];
char copyowner[IDLEN + 2];
} CopyQueue ;
+#define COPYQUEUE_COMMON_SIZE (10)
+
static CopyQueue *copyqueue;
static int allocated_copyqueue = 0, used_copyqueue = 0, head_copyqueue = 0;
@@ -34,13 +40,21 @@ int copyqueue_append(CopyQueue *pcq)
if(head_copyqueue == used_copyqueue)
{
// empty queue, happy happy reset
+ if(allocated_copyqueue > COPYQUEUE_COMMON_SIZE)
+ {
+ // let's reduce it
+ allocated_copyqueue = COPYQUEUE_COMMON_SIZE;
+ copyqueue = (CopyQueue*)realloc( copyqueue,
+ allocated_copyqueue * sizeof(CopyQueue));
+ }
head_copyqueue = used_copyqueue = 0;
}
used_copyqueue ++;
if(used_copyqueue > allocated_copyqueue)
{
- allocated_copyqueue = used_copyqueue + 10; // half page
+ allocated_copyqueue =
+ used_copyqueue + COPYQUEUE_COMMON_SIZE; // half page
copyqueue = (CopyQueue*) realloc (copyqueue,
sizeof(CopyQueue) * allocated_copyqueue);
if(!copyqueue)