~ubuntu-branches/ubuntu/vivid/tin/vivid

« back to all changes in this revision

Viewing changes to src/memory.c

  • Committer: Package Import Robot
  • Author(s): Marco d'Itri
  • Date: 2012-01-06 15:04:11 UTC
  • mfrom: (1.2.17)
  • Revision ID: package-import@ubuntu.com-20120106150411-vftxaked1sscxt1t
Tags: 1:2.1.0-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 *  Module    : memory.c
4
4
 *  Author    : I. Lea & R. Skrenta
5
5
 *  Created   : 1991-04-01
6
 
 *  Updated   : 2010-05-16
 
6
 *  Updated   : 2011-11-14
7
7
 *  Notes     :
8
8
 *
9
 
 * Copyright (c) 1991-2011 Iain Lea <iain@bricbrac.de>, Rich Skrenta <skrenta@pbm.com>
 
9
 * Copyright (c) 1991-2012 Iain Lea <iain@bricbrac.de>, Rich Skrenta <skrenta@pbm.com>
10
10
 * All rights reserved.
11
11
 *
12
12
 * Redistribution and use in source and binary forms, with or without
49
49
int max_newnews;
50
50
int num_newnews = 0;
51
51
int max_art;
 
52
int max_base;
52
53
int max_save;
53
54
int num_save = 0;
54
55
int max_scope;
58
59
 * Dynamic arrays
59
60
 */
60
61
int *my_group;                          /* .newsrc --> active[] */
61
 
long *base;                             /* base articles for each thread */
 
62
t_artnum *base;                         /* base articles for each thread */
62
63
struct t_group *active;                 /* active newsgroups */
63
64
struct t_scope *scopes = NULL;  /* attributes stores in .tin/attributes */
64
65
struct t_newnews *newnews;              /* active file sizes on differnet servers */
101
102
         * article headers array
102
103
         */
103
104
        max_art = DEFAULT_ARTICLE_NUM;
 
105
        max_base = DEFAULT_ARTICLE_NUM;
104
106
 
105
107
        arts = my_calloc(1, sizeof(*arts) * max_art);
106
 
        base = my_malloc(sizeof(long) * max_art);
 
108
        base = my_malloc(sizeof(t_artnum) * max_base);
107
109
 
108
110
        ofmt = my_calloc(1, sizeof(*ofmt) * 9); /* initial number of overview fields */
109
111
 
134
136
 
135
137
        max_art += max_art >> 1;                /* increase by 50% */
136
138
        arts = my_realloc(arts, sizeof(*arts) * max_art);
137
 
        base = my_realloc(base, sizeof(long) * max_art);
138
139
        for (; i < max_art; i++)                /* use memset() instead? */
139
140
                arts[i].subject = arts[i].from = arts[i].xref = arts[i].refs = arts[i].msgid = NULL;
140
141
}
156
157
 
157
158
 
158
159
void
 
160
expand_base(
 
161
        void)
 
162
{
 
163
        max_base += max_base >> 1;              /* increase by 50% */
 
164
        base = my_realloc(base, sizeof(t_artnum) * max_base);
 
165
}
 
166
 
 
167
 
 
168
void
159
169
expand_save(
160
170
        void)
161
171
{
308
318
        int i;
309
319
 
310
320
        for_each_art(i) {
311
 
                arts[i].artnum = 0L;
 
321
                arts[i].artnum = T_ARTNUM_CONST(0);
312
322
                arts[i].date = (time_t) 0;
313
323
                FreeAndNull(arts[i].xref);
314
324
 
506
516
#endif /* DEBUG */
507
517
 
508
518
        if ((p = malloc(size)) == NULL) {
509
 
                error_message(2, txt_out_of_memory, tin_progname, size, file, line);
 
519
                error_message(2, txt_out_of_memory, tin_progname, (unsigned long) size, file, line);
510
520
                giveup();
511
521
        }
512
522
        return p;
530
540
#endif /* DEBUG */
531
541
 
532
542
        if ((p = calloc(nmemb, size)) == NULL) {
533
 
                error_message(2, txt_out_of_memory, tin_progname, nmemb * size, file, line);
 
543
                error_message(2, txt_out_of_memory, tin_progname, (unsigned long) (nmemb * size), file, line);
534
544
                giveup();
535
545
        }
536
546
        return p;
558
568
        p = ((!p) ? (malloc(size)) : realloc(p, size));
559
569
 
560
570
        if (p == NULL) {
561
 
                error_message(2, txt_out_of_memory, tin_progname, size, file, line);
 
571
                error_message(2, txt_out_of_memory, tin_progname, (unsigned long) size, file, line);
562
572
                giveup();
563
573
        }
564
574
        return p;