Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pa4
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nilesh Jagdish
pa4
Commits
ef7f340a
Commit
ef7f340a
authored
Nov 10, 2020
by
Bandana
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update persistentStorage.c
parent
116d4cbd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
24 deletions
+14
-24
persistentStorage.c
persistentStorage.c
+14
-24
No files found.
persistentStorage.c
View file @
ef7f340a
...
...
@@ -40,13 +40,6 @@ struct n2
struct
n1
*
h1
=
NULL
;
struct
n2
*
h2
=
NULL
;
unsigned
int
nooffiles
=
0
;
void
initializeStorageVariables
()
{
pthread_mutex_init
(
&
m
,
NULL
);
sem_init
(
&
w
,
0
,
1
);
}
struct
n2
*
check
(
struct
n2
*
h2
){
while
(
1
)
{
...
...
@@ -568,7 +561,7 @@ struct n1* del(struct n1*r,char *key){
}
str
ing
GETT
(
char
*
key
){
str
uct
n1
*
GETT
(
char
*
key
){
pthread_mutex_lock
(
&
m
);
readercout
+=
1
;
if
(
readercout
==
1
){
...
...
@@ -601,24 +594,20 @@ string GETT(char * key){
pthread_mutex_unlock
(
&
m
);
return
result
;
return
dh
;
}
else
{
//
printf("%s = %s \n",key ,dh->key);
printf
(
"%s = %s
\n
"
,
key
,
dh
->
key
);
if
((
tt
=
strcmp
(
key
,
dh
->
key
))
==
0
)
{
char
filename2
[
10
];
strcpy
(
filename2
,
dh
->
filename
);
int
fd1
=
open
(
strcat
(
filename2
,
".txt"
),
O_RDWR
);
FILE
*
f
=
fopen
(
strcat
(
filename2
,
".txt"
),
"r"
);
char
record
[
257
];
lseek
(
fd1
,
dh
->
lineno
*
257
,
SEEK_SET
);
// fgets(record,256,f);
read
(
fd1
,
record
,
256
);
// fclose(f);
write
(
STDOUT_FILENO
,
record
,
256
);
write
(
STDOUT_FILENO
,
"
\n
"
,
1
);
close
(
fd1
);
fseek
(
f
,
dh
->
lineno
*
257
,
SEEK_SET
);
fgets
(
record
,
256
,
f
);
fclose
(
f
);
int
sp
=
0
;
while
(
record
[
sp
]
!=
'#'
)
{
...
...
@@ -637,7 +626,7 @@ string GETT(char * key){
pthread_mutex_unlock
(
&
m
);
return
result
;
return
dh
;
}
else
if
(
tt
>
0
)
...
...
@@ -653,7 +642,7 @@ string GETT(char * key){
void
PUTT
(
char
*
key
,
char
*
value
){
sem_wait
(
&
w
);
//
printf("key = %s\nvalue=%s",key, value);
printf
(
"key = %s
\n
value=%s"
,
key
,
value
);
h1
=
insert
(
h1
,
key
);
char
filename2
[
10
];
strcpy
(
filename2
,
add
->
filename
);
...
...
@@ -707,7 +696,7 @@ void PUTT(char *key,char *value){
write
(
n
,
ts
,
257
);
close
(
n
);
}
//
printf("PUTT completed\n");
printf
(
"PUTT completed
\n
"
);
sem_post
(
&
w
);
}
...
...
@@ -794,7 +783,7 @@ void pp(struct n1*r){
}
pp
(
r
->
p1
);
//
printf("%s\n",r->key);
printf
(
"%s
\n
"
,
r
->
key
);
pp
(
r
->
p2
);
}
...
...
@@ -802,7 +791,7 @@ void pp2(struct n1*r){
if
(
r
==
NULL
){
return
;
}
//
printf("%s\n",r->key);
printf
(
"%s
\n
"
,
r
->
key
);
pp2
(
r
->
p1
);
...
...
@@ -813,7 +802,8 @@ void pp2(struct n1*r){
// int main()
// {
// printf("Saikumar\n");
// PUTT("1",);
// return 0;
// }
...
...
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