aboutsummaryrefslogtreecommitdiffstats
path: root/mail/pathalias/files/patch-mem.c
blob: 94615fa30d8aee83b59f4cc08f88c6dead90b0b2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
--- mem.c.orig  1993-03-03 22:11:23.000000000 +0100
+++ mem.c   2013-06-16 17:14:35.000000000 +0200
@@ -1,38 +1,40 @@
 /* pathalias -- by steve bellovin, as told to peter honeyman */
 #ifndef lint
-static char    *sccsid = "@(#)mem.c    9.6 92/08/25";
+static const char  *sccsid = "@(#)mem.c    9.6 92/08/25";
 #endif
 
+#include <stdlib.h>
 #include "def.h"
+#include <string.h>
 
 /* exports */
 long Ncount;
-extern void freelink(), wasted(), freetable();
-extern long allocation();
 
 /* imports */
 extern char *Netchars;
 extern int Vflag;
-extern void die();
-extern int strlen();
 #ifdef DEBUG
-extern char *sbrk();
+#include <unistd.h>
+#endif
+
+#ifdef MYMALLOC
+STATIC void addtoheap(char *p, long size);
 #endif
 
 /* privates */
-STATIC void nomem();
-static link *Lcache;
-static unsigned int Memwaste;
+STATIC void nomem(void);
+static palink *Lcache;
+static unsigned long Memwaste;
 
-link   *
+palink *
 newlink()
-{  register link *rval;
+{  register palink *rval;
 
    if (Lcache) {
        rval = Lcache;
        Lcache = Lcache->l_next;
-       strclear((char *) rval, sizeof(link));
-   } else if ((rval = (link * ) calloc(1, sizeof(link))) == 0)
+       strclear((char *) rval, sizeof(palink));
+   } else if ((rval = (palink * ) calloc(1, sizeof(palink))) == 0)
        nomem();
    return rval;
 }
@@ -40,7 +42,7 @@
 /* caution: this destroys the contents of l_next */
 void
 freelink(l)
-   link *l;
+   palink *l;
 {
    l->l_next = Lcache;
    Lcache = l;
@@ -69,7 +71,7 @@
 
 char   *
 strsave(s)
-   char *s;
+   const char *s;
 {  register char *r;
 
    if ((r = malloc((unsigned) strlen(s) + 1)) == 0)
@@ -105,8 +107,6 @@
    long size;
 {
 #ifdef MYMALLOC
-   STATIC void addtoheap();
-
    addtoheap((char *) t, size * sizeof(node *));
 #else
    free((char *) t);
@@ -163,10 +163,9 @@
 #undef calloc
 
 /* imports */
-extern char *malloc(), *calloc();
 
 /* private */
-STATIC int align();
+STATIC int align(char *n);
 
 /* allocate in MBUFSIZ chunks.  4k works ok (less 16 for malloc quirks). */
 #define MBUFSIZ (4 * 1024 - 16)