 		printf("doc %d: %4.2f\n", i, docScores[i]);
 	}
 
-	cudaFree(d_queryTerms);
-	cudaFree(d_docScores);
+	cudaFree(dev_queryTerms);
+	cudaFree(dev_docScores);
   free(queryTerms);
 }
 

	printf("Copying postings from host to device\n");

  // POSTINGS TO DEVICE
	checkCuda( cudaMalloc((void**)&d_postings, sizeof(Posting) * terms) );
	checkCuda( cudaMemcpy(d_postings, postingsLoaded, sizeof(Posting) * terms, cudaMemcpyHostToDevice) );
	int i;
	int *d_docIds;
	float *d_weights;
	for (i = 0; i < terms; i++) {
		Posting p = postingsLoaded[i];

		checkCuda( cudaMalloc((void**) &d_docIds, sizeof(int) * p.docsLength) );
		checkCuda( cudaMalloc((void**) &d_weights, sizeof(float) * p.docsLength) );

		checkCuda( cudaMemcpy(&(d_postings[i].docIds), &(d_docIds), sizeof(int *), cudaMemcpyHostToDevice) );
		checkCuda( cudaMemcpy(&(d_postings[i].weights), &(d_weights), sizeof(float *), cudaMemcpyHostToDevice) );

		checkCuda( cudaMemcpy(d_docIds, p.docIds, sizeof(int) * p.docsLength, cudaMemcpyHostToDevice) );
		checkCuda( cudaMemcpy(d_weights, p.weights, sizeof(float) * p.docsLength, cudaMemcpyHostToDevice) );

	}


void displayPosting(Posting *postings, int size);

// global variables that are allocated in device during indexing
Posting *dev_postings;
float *dev_docsNorm;
int terms;
int docs;
