summaryrefslogtreecommitdiff
path: root/ex5-7.c
diff options
context:
space:
mode:
Diffstat (limited to 'ex5-7.c')
-rw-r--r--ex5-7.c48
1 files changed, 24 insertions, 24 deletions
diff --git a/ex5-7.c b/ex5-7.c
index 2d277ad..1457410 100644
--- a/ex5-7.c
+++ b/ex5-7.c
@@ -3,25 +3,25 @@
// An extremely simple allocation system.
// Memory must be freed in the reverse order it was allocated.
-#define ALLOCSIZE 10000
-
-static char allocbuf[ALLOCSIZE];
-static char *allocp = allocbuf;
-
-char *alloc(int n) {
- if (allocbuf + ALLOCSIZE - allocp >= n) {
- allocp += n;
- return allocp - n;
- } else {
- return NULL;
- }
-}
-
-void afree(char *p) {
- if (p >= allocbuf && p < allocbuf + ALLOCSIZE) {
- allocp = p;
- }
-}
+// #define ALLOCSIZE 10000
+
+// static char allocbuf[ALLOCSIZE];
+// static char *allocp = allocbuf;
+
+// char *alloc(int n) {
+// if (allocbuf + ALLOCSIZE - allocp >= n) {
+// allocp += n;
+// return allocp - n;
+// } else {
+// return NULL;
+// }
+// }
+
+// void afree(char *p) {
+// if (p >= allocbuf && p < allocbuf + ALLOCSIZE) {
+// allocp = p;
+// }
+// }
#define MAXLINES 5000
@@ -47,7 +47,7 @@ int main() {
#define MAXLEN 1000
int z_getline(char*, int);
-char* alloc(int);
+// char* alloc(int);
int readlines(char* lineptr[], int maxlines) {
int len;
@@ -71,9 +71,10 @@ void writelines(char* lineptr[], int nlines) {
printf("%s\n", lineptr[i]);
}
-void qsort(char* v[], int left, int right) {
- int i, last;
- void swap(char* v[], int i, int j);
+void swap(char* v[], int i, int j);
+
+void qsort(char* v[], const int left, const int right) {
+ int i, last;
if (left >= right) {
return;
}
@@ -95,7 +96,6 @@ void swap(char* v[], int i, int j) {
v[j] = temp;
}
-
/* getline: read a line into s, return length */
int z_getline(char s[], int lim) {
int c, i;