w2v-server.pl: localize variables in C section
diff --git a/w2v-server.pl b/w2v-server.pl
index 149dfbf..8c7d048 100644
--- a/w2v-server.pl
+++ b/w2v-server.pl
@@ -48,25 +48,22 @@
 //the thread function
 void *connection_handler(void *);
  
-char *bestw[MAX_NEIGHBOURS];
-char file_name[max_size], st[100][max_size];
-float dist, len, bestd[MAX_NEIGHBOURS], vec[max_size];
-long long words, size, a, b, c, d, cn, bi[100], besti[MAX_NEIGHBOURS];
-char ch;
 float *M;
 char *vocab;
-char *stringBuffer;
+long long words, size;
 
 int init_net(char *file_name) {
   FILE *f, *binvecs, *binwords;
 	int binwords_fd, binvecs_fd;
+	long long a, b, c, d, cn;
+	float len;
+
 	char binvecs_fname[256], binwords_fname[256];
 	strcpy(binwords_fname, file_name);
 	strcat(binwords_fname, ".words");
 	strcpy(binvecs_fname, file_name);
 	strcat(binvecs_fname, ".vecs");
 
-	stringBuffer = malloc(64000);
   f = fopen(file_name, "rb");
   if (f == NULL) {
     printf("Input file %s not found\n", file_name);
@@ -75,7 +72,6 @@
   fscanf(f, "%lld", &words);
 	if(MAX_WORDS > 0 && words > MAX_WORDS) words = MAX_WORDS;
   fscanf(f, "%lld", &size);
-  for (a = 0; a < MAX_NEIGHBOURS; a++) bestw[a] = (char *)malloc(max_size * sizeof(char));
 	if( (binvecs_fd = open(binvecs_fname, O_RDONLY)) >= 0 && (binwords_fd = open(binwords_fname, O_RDONLY)) >= 0) {
 		M = mmap(0, sizeof(float) * (long long)words * (long long)size, PROT_READ, MAP_PRIVATE, binvecs_fd, 0);
 		vocab = mmap(0,  sizeof(char) * (long long)words * max_w, PROT_READ, MAP_PRIVATE, binwords_fd, 0);
@@ -118,10 +114,15 @@
 }
 
 SV *get_neighbours(char *st1, int N) {
+	char *bestw[MAX_NEIGHBOURS];
+	char file_name[max_size], st[100][max_size];
+	float dist, len, bestd[MAX_NEIGHBOURS], vec[max_size];
+	long long a, b, c, d, cn, bi[100], besti[MAX_NEIGHBOURS];
+	char ch;
+
   if(N>MAX_NEIGHBOURS) N=MAX_NEIGHBOURS;
 
-	FILE *out=stdout;
-	*stringBuffer=0;
+  for (a = 0; a < MAX_NEIGHBOURS; a++) bestw[a] = (char *)malloc(max_size * sizeof(char));
 	float worstbest=0;
 
 	for (a = 0; a < N; a++) bestd[a] = 0;