aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--read.c16
-rw-r--r--strbst.c6
2 files changed, 12 insertions, 10 deletions
diff --git a/read.c b/read.c
index b1b4789..37fefb0 100644
--- a/read.c
+++ b/read.c
@@ -8,14 +8,14 @@
#include "nodelink.h"
#include "ll.h"
-void consumespaces(FILE* file) {
+static void consumespaces(FILE* file) {
// used to consume spaces in an item ("- list item" -> "list item")
int c;
while ( ( c = fgetc(file) ) != EOF && c == ' ' );
ungetc(c, file);
}
-void wsclean(char* txt, size_t sz){ // "string \n \n" -> "string"
+static void wsclean(char* txt, size_t sz){ // "string\n \n" -> "string"
size_t i;
for (i = sz; i > 0; i--) { // start at end [i-1] and dec
// break on non-nl, non-space char
@@ -24,14 +24,14 @@ void wsclean(char* txt, size_t sz){ // "string \n \n" -> "string"
txt[i] = 0; // finish string
}
-char* empty(void) {
+static char* empty(void) {
// "" with a freeable memory address
char* str = malloc(sizeof(char));
*str = 0;
return str;
}
-char* getline(size_t* n, FILE* file) {
+static char* getline(size_t* n, FILE* file) {
size_t sz = 100;
*n = 0;
int c;
@@ -47,7 +47,7 @@ char* getline(size_t* n, FILE* file) {
return realloc(out, sizeof(char) * (*n+1) );
}
-char* line(FILE* file) { // gets a line from file
+static char* line(FILE* file) { // gets a line from file
size_t n;
char* link = getline(&n, file);
// getline stores a line of size n in link
@@ -61,7 +61,7 @@ char* line(FILE* file) { // gets a line from file
}
}
-link* insorget(strbst* tgt, char* name) {
+static link* insorget(strbst* tgt, char* name) {
link* get = query(tgt, name);
if (!get) {
get = newlink(newnode());
@@ -70,13 +70,13 @@ link* insorget(strbst* tgt, char* name) {
return get;
}
-link* addbstlink(strbst* tree, char* name, node* to) {
+static link* addbstlink(strbst* tree, char* name, node* to) {
link* l = newlink(to);
insbst(tree, name, l);
return l;
}
-char* resolvell(llnode* tail, size_t sz) {
+static char* resolvell(llnode* tail, size_t sz) {
char *out, *pos;
pos = out = malloc(sizeof(char)*(sz+1)); out[sz] = 0;
while (tail != NULL) {
diff --git a/strbst.c b/strbst.c
index b8b5dce..16c2e61 100644
--- a/strbst.c
+++ b/strbst.c
@@ -58,8 +58,10 @@ e b => a c
*bst = (*bst)->right; // tip = b
(*bst)->left->right = flip;
}
+// NOTE: These functions are valid because `b` is guaranteed in the
+// conditions where the rotations are called.
-int insnode(strbstnode** bst, strbstnode* new) {
+static int insnode(strbstnode** bst, strbstnode* new) {
// returns height of right node minus height of left node ("bias")
if (!*bst) { // When an empty node is reached,
*bst = new; // place the node
@@ -96,7 +98,7 @@ void insbst(strbst* bst, char* ind, void* data) {
insnode(&(bst->head), newbstnode(ind, data)); // allows recursion
}
-void* querynode(strbstnode* node, char* ind){
+static void* querynode(strbstnode* node, char* ind){
// tail-recursive finding algorithm
if (!node) return NULL; // NULL => node not found
int cmp = strcmp(ind, node->ind);