Commit f71cd6db authored by Samarth Joshi's avatar Samarth Joshi

strcmp instead of == to compare strings

parent c3382784
No preview for this file type
...@@ -42,12 +42,15 @@ int main(int argc, char const *argv[]) ...@@ -42,12 +42,15 @@ int main(int argc, char const *argv[])
char key2[256]="test"; char key2[256]="test";
char value2[256]="cdde"; char value2[256]="cdde";
char error2[256]; char error2[256];
char value3[256];
//printf("%d",(int)put(sock,key, value,error)); //printf("%d",(int)put(sock,key, value,error));
//printf("%d",(int)del(sock,key,error)); //printf("%d",(int)del(sock,key,error));
//printf("%d",(int)get(sock,key, value,error)); //printf("%d",(int)get(sock,key, value,error));
//while (1) { //while (1) {
printf("%d",(int)put(sock, key1, value1, error1)); printf("%d",(int)put(sock, key1, value1, error1));
printf("%d",(int)put(sock, key2, value2, error2)); printf("%d",(int)put(sock, key2, value2, error2));
printf("%d",(int)get(sock, key1, value3, error2));
return 0; return 0;
} }
\ No newline at end of file
...@@ -70,7 +70,7 @@ int cache_del(char *key) ...@@ -70,7 +70,7 @@ int cache_del(char *key)
{ {
for(int i=0;i<MAX_SIZE;i++) for(int i=0;i<MAX_SIZE;i++)
{ {
if(array[i]->key == key) if(strcmp(array[i]->key , key) == 0)
{ {
while(ATOMIC_TEST_AND_SET(&(array[i]->lock),1) == 1); while(ATOMIC_TEST_AND_SET(&(array[i]->lock),1) == 1);
remove_element_from_deque(key); remove_element_from_deque(key);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment