Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
key-value-store
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Samarth Joshi
key-value-store
Commits
811d30c1
Commit
811d30c1
authored
Nov 09, 2020
by
Roshan Rabinarayan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hopefully final
parent
1b5d4448
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
8 deletions
+11
-8
temp.c
temp.c
+11
-8
No files found.
temp.c
View file @
811d30c1
...
...
@@ -33,10 +33,13 @@ unsigned modulus( unsigned char *num, size_t size, unsigned divisor) {
void
file_del
(
char
*
key
)
{
int
index
=
modulus
(
key
,
256
,
setSize
);
lseek
(
fds
[
index
],
0
,
SEEK_SET
);
fflush
(
stdout
);
int
length
=
0
;
sem_wait
(
&
mutex
[
index
]);
char
blankspace
[
512
];
char
ch
;
int
k
=-
1
;
lseek
(
fds
[
index
],
0
,
SEEK_SET
);
memset
(
blankspace
,
0
,
512
);
char
*
line
;
char
temp
[
514
];
...
...
@@ -52,12 +55,13 @@ void file_del( char *key)
if
(
strcmp
(
key
,
fkey
)
==
0
){
lseek
(
fds
[
index
],
position
,
SEEK_SET
);
write
(
fds
[
index
],
blankspace
,
strlen
(
temp
));
puts
(
temp
);
break
;
}
position
=
ftell
(
fp
);
}
printf
(
"length %d"
,
length
);
sem_post
(
&
mutex
[
index
]);
}
...
...
@@ -131,7 +135,7 @@ off_t file_put(char *key,char *value)
printf
(
"value:(%s)(%s)
\n
"
,
fvalue
,
value
);
fflush
(
stdout
);
fseek
(
fp
,
position
,
SEEK_SET
);
snprintf
(
lin
,
s
izeof
(
lin
)
,
"%s:%s
\n
"
,
key
,
value
);
snprintf
(
lin
,
s
trlen
(
key
)
+
strlen
(
value
)
+
2
,
"%s:%s
\n
"
,
key
,
value
);
if
(
fputs
(
lin
,
fp
)
<
0
)
printf
(
"
\n
[unable to perform file_put]
\n
"
);
return
0
;
...
...
@@ -187,10 +191,9 @@ int main()
//file_get(prevkey, value); // Doesnot depend on key arg, returns key and value at offset 0
//printf("(%s)", value);
//file_del("29");
file_get
(
"24"
,
value
);
printf
(
"(%s)
\n
"
,
value
);
memset
(
value
,
0
,
sizeof
(
value
));
file_get
(
"21"
,
value
);
printf
(
"(%s)
\n
"
,
value
);
//file_get("24",value);
// printf("(%s)\n", value);
file_del
(
"21"
);
//printf("(%s)\n", value);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment