Skip to content

Commit f7c583c

Browse files
committed
Reformat.
1 parent f9b150b commit f7c583c

File tree

6 files changed

+109
-93
lines changed

6 files changed

+109
-93
lines changed

modules/src/alloc/Salloc.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,25 @@
77

88
/* The memory allocation routines offered in this file are:
99
10-
char *Salloc(str, n) : allocate n bytes, initialized with the string
11-
str
10+
char *Salloc(str, n) : allocate n bytes, initialized with the string
11+
str
1212
*/
1313

1414
#if __STDC__
1515
#include <stdlib.h>
1616
#else
17-
extern char *malloc();
17+
extern char* malloc();
1818
#endif
1919

20-
#include "alloc.h"
20+
#include "alloc.h"
2121

22-
char *Salloc(char *str, unsigned int sz)
22+
char* Salloc(char* str, unsigned int sz)
2323
{
2424
/* Salloc() is not a primitive function: it just allocates a
25-
piece of storage and copies a given string into it.
25+
piece of storage and copies a given string into it.
2626
*/
27-
char *res = malloc(sz);
28-
char *m = res;
27+
char* res = malloc(sz);
28+
char* m = res;
2929

3030
while (sz--)
3131
*m++ = *str++;

modules/src/alloc/alloc.h

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,35 +8,32 @@
88
/* PROGRAM'S INTERFACE TO MEMORY ALLOCATION ROUTINES */
99

1010
/* This file serves as the interface between the program and the
11-
memory allocating routines.
12-
There are 3 memory allocation routines:
13-
char *malloc(n) allocate n bytes
14-
char *Salloc(str, n) allocate n bytes and fill them with
15-
string str
11+
memory allocating routines.
12+
There are 3 memory allocation routines:
13+
char *malloc(n) allocate n bytes
14+
char *Salloc(str, n) allocate n bytes and fill them with
15+
string str
1616
*/
1717

18-
char *Salloc(char *, unsigned int);
19-
char *st_alloc(char **, unsigned int, int);
20-
char *std_alloc(char **, unsigned int, int, int *);
21-
void clear(char *, unsigned int);
22-
void botch(char *, unsigned int);
18+
char* Salloc(char*, unsigned int);
19+
char* st_alloc(char**, unsigned int, int);
20+
char* std_alloc(char**, unsigned int, int, int*);
21+
void clear(char*, unsigned int);
22+
void botch(char*, unsigned int);
2323

2424
/* S T R U C T U R E - S T O R A G E D E F I N I T I O N S */
2525

26-
typedef struct _ALLOC_ {
27-
struct _ALLOC_ *_A_next;
28-
} *_PALLOC_;
26+
typedef struct _ALLOC_
27+
{
28+
struct _ALLOC_* _A_next;
29+
}* _PALLOC_;
2930

30-
31-
#define _A_st_free(ptr, phead, size) (((_PALLOC_)ptr)->_A_next = \
32-
(_PALLOC_)(*phead), \
33-
*((_PALLOC_ *)phead) = \
34-
(_PALLOC_) ptr)
35-
#ifndef BOTCH_FREE
36-
#define st_free(ptr, phead, size) _A_st_free(ptr, phead, size)
37-
#else /* def BOTCH_FREE */
38-
#define st_free(ptr, phead, size) (botch((char *)(ptr), size), \
39-
_A_st_free(ptr, phead, size))
40-
#endif /* BOTCH_FREE */
31+
#define _A_st_free(ptr, phead, size) \
32+
(((_PALLOC_)ptr)->_A_next = (_PALLOC_)(*phead), *((_PALLOC_*)phead) = (_PALLOC_)ptr)
33+
#ifndef BOTCH_FREE
34+
#define st_free(ptr, phead, size) _A_st_free(ptr, phead, size)
35+
#else /* def BOTCH_FREE */
36+
#define st_free(ptr, phead, size) (botch((char*)(ptr), size), _A_st_free(ptr, phead, size))
37+
#endif /* BOTCH_FREE */
4138

4239
#endif /* __ALLOC_INCLUDED__ */

modules/src/alloc/botch.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,19 @@
44
* See the copyright notice in the ACK home directory, in the file "Copyright".
55
*/
66
/* botch - write garbage over a chunk of memory, useful if you want
7-
to check if freed memory is used inappopriately.
7+
to check if freed memory is used inappopriately.
88
*/
99

1010
#include "alloc.h"
1111

12-
void botch(char *ptr, unsigned int n)
12+
void botch(char* ptr, unsigned int n)
1313
{
14-
while (n >= sizeof (long)) {
15-
/* high-speed botch loop */
16-
*(long *)ptr = 025252525252L;
17-
ptr += sizeof (long), n -= sizeof (long);
14+
while (n >= sizeof(long))
15+
{
16+
/* high-speed botch loop */
17+
*(long*)ptr = 025252525252L;
18+
ptr += sizeof(long), n -= sizeof(long);
1819
}
19-
while (n--) *ptr++ = '\252';
20+
while (n--)
21+
*ptr++ = '\252';
2022
}

modules/src/alloc/clear.c

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,19 @@
44
* See the copyright notice in the ACK home directory, in the file "Copyright".
55
*/
66
/* clear - clear a block of memory, and try to do it fast.
7-
*/
7+
*/
88

99
#include "alloc.h"
1010

1111
/* instead of Calloc: */
1212

13-
void clear(char *ptr, unsigned int n)
13+
void clear(char* ptr, unsigned int n)
1414
{
15-
long *q = (long *) ptr;
15+
long* q = (long*)ptr;
1616

17-
while (n >= 8*sizeof (long)) {
18-
/* high-speed clear loop */
17+
while (n >= 8 * sizeof(long))
18+
{
19+
/* high-speed clear loop */
1920
*q++ = 0;
2021
*q++ = 0;
2122
*q++ = 0;
@@ -24,13 +25,15 @@ void clear(char *ptr, unsigned int n)
2425
*q++ = 0;
2526
*q++ = 0;
2627
*q++ = 0;
27-
n -= 8*sizeof (long);
28+
n -= 8 * sizeof(long);
2829
}
29-
while (n >= sizeof (long)) {
30-
/* high-speed clear loop */
30+
while (n >= sizeof(long))
31+
{
32+
/* high-speed clear loop */
3133
*q++ = 0;
32-
n -= sizeof (long);
34+
n -= sizeof(long);
3335
}
34-
ptr = (char *) q;
35-
while (n--) *ptr++ = '\0';
36+
ptr = (char*)q;
37+
while (n--)
38+
*ptr++ = '\0';
3639
}

modules/src/alloc/st_alloc.c

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,43 +4,48 @@
44
* See the copyright notice in the ACK home directory, in the file "Copyright".
55
*/
66
/* st_alloc - get a structure from a free list. If no structures left,
7-
create new ones.
8-
The counterpart, st_free, is a macro, defined in alloc.h
7+
create new ones.
8+
The counterpart, st_free, is a macro, defined in alloc.h
99
*/
1010

1111
#if __STDC__
1212
#include <stdlib.h>
1313
#else
14-
extern char *malloc();
14+
extern char* malloc();
1515
#ifndef NULL
1616
#define NULL 0
1717
#endif
1818
#endif
1919

20-
#include "alloc.h"
20+
#include "alloc.h"
2121

22-
char *st_alloc(char **phead, unsigned int size, int count)
22+
char* st_alloc(char** phead, unsigned int size, int count)
2323
{
24-
char *p = NULL;
25-
long *q;
26-
char *retval;
24+
char* p = NULL;
25+
long* q;
26+
char* retval;
2727

28-
if (*phead == 0) {
29-
while (count >= 1 && (p = malloc(size * count)) == 0) {
28+
if (*phead == 0)
29+
{
30+
while (count >= 1 && (p = malloc(size * count)) == 0)
31+
{
3032
count >>= 1;
3133
}
32-
((_PALLOC_) p)->_A_next = 0;
33-
while (--count) {
34+
((_PALLOC_)p)->_A_next = 0;
35+
while (--count)
36+
{
3437
p += size;
35-
((_PALLOC_) p)->_A_next = (_PALLOC_) (p - size);
38+
((_PALLOC_)p)->_A_next = (_PALLOC_)(p - size);
3639
}
3740
*phead = p;
3841
}
39-
else p = *phead;
40-
*phead = (char *) (((_PALLOC_)p)->_A_next);
42+
else
43+
p = *phead;
44+
*phead = (char*)(((_PALLOC_)p)->_A_next);
4145
retval = p;
42-
q = (long *) p;
43-
while (size >= 8*sizeof(long)) {
46+
q = (long*)p;
47+
while (size >= 8 * sizeof(long))
48+
{
4449
*q++ = 0;
4550
*q++ = 0;
4651
*q++ = 0;
@@ -49,14 +54,16 @@ char *st_alloc(char **phead, unsigned int size, int count)
4954
*q++ = 0;
5055
*q++ = 0;
5156
*q++ = 0;
52-
size -= 8*sizeof(long);
57+
size -= 8 * sizeof(long);
5358
}
54-
while (size >= sizeof(long)) {
59+
while (size >= sizeof(long))
60+
{
5561
*q++ = 0;
5662
size -= sizeof(long);
5763
}
58-
p = (char *) q;
64+
p = (char*)q;
5965

60-
while (size--) *p++ = 0;
66+
while (size--)
67+
*p++ = 0;
6168
return retval;
6269
}

modules/src/alloc/std_alloc.c

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,42 +4,47 @@
44
* See the copyright notice in the ACK home directory, in the file "Copyright".
55
*/
66
/* std_alloc - get a structure from a free list. If no structures left,
7-
create new ones.
8-
The counterpart, st_free, is a macro, defined in alloc.h
9-
This is a counting version of st_alloc.
7+
create new ones.
8+
The counterpart, st_free, is a macro, defined in alloc.h
9+
This is a counting version of st_alloc.
1010
*/
1111

1212
#if __STDC__
1313
#include <stdlib.h>
1414
#else
15-
extern char *malloc();
15+
extern char* malloc();
1616
#endif
1717

18-
#include "alloc.h"
18+
#include "alloc.h"
1919

20-
char *std_alloc(char **phead, unsigned int size, int count, int *pcnt)
20+
char* std_alloc(char** phead, unsigned int size, int count, int* pcnt)
2121
{
22-
char *p;
23-
long *q;
24-
char *retval;
22+
char* p;
23+
long* q;
24+
char* retval;
2525

26-
if (*phead == 0) {
27-
while (count >= 1 && (p = malloc(size * count)) == 0) {
26+
if (*phead == 0)
27+
{
28+
while (count >= 1 && (p = malloc(size * count)) == 0)
29+
{
2830
count >>= 1;
2931
}
3032
*pcnt += count;
31-
((_PALLOC_) p)->_A_next = 0;
32-
while (--count) {
33+
((_PALLOC_)p)->_A_next = 0;
34+
while (--count)
35+
{
3336
p += size;
34-
((_PALLOC_) p)->_A_next = (_PALLOC_) (p - size);
37+
((_PALLOC_)p)->_A_next = (_PALLOC_)(p - size);
3538
}
3639
*phead = p;
3740
}
38-
else p = *phead;
39-
*phead = (char *) (((_PALLOC_) p)->_A_next);
41+
else
42+
p = *phead;
43+
*phead = (char*)(((_PALLOC_)p)->_A_next);
4044
retval = p;
41-
q = (long *) p;
42-
while (size >= 8*sizeof(long)) {
45+
q = (long*)p;
46+
while (size >= 8 * sizeof(long))
47+
{
4348
*q++ = 0;
4449
*q++ = 0;
4550
*q++ = 0;
@@ -48,14 +53,16 @@ char *std_alloc(char **phead, unsigned int size, int count, int *pcnt)
4853
*q++ = 0;
4954
*q++ = 0;
5055
*q++ = 0;
51-
size -= 8*sizeof(long);
56+
size -= 8 * sizeof(long);
5257
}
53-
while (size >= sizeof(long)) {
58+
while (size >= sizeof(long))
59+
{
5460
*q++ = 0;
5561
size -= sizeof(long);
5662
}
57-
p = (char *) q;
63+
p = (char*)q;
5864

59-
while (size--) *p++ = 0;
65+
while (size--)
66+
*p++ = 0;
6067
return retval;
6168
}

0 commit comments

Comments
 (0)