Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
e51fa063
Commit
e51fa063
authored
May 05, 2010
by
Pieter Noordhuis
Browse files
str can be free'd outside readString
parent
57ca68ac
Changes
1
Hide whitespace changes
Inline
Side-by-side
redis-check-aof.c
View file @
e51fa063
...
@@ -58,13 +58,9 @@ int readString(FILE *fp, char** target) {
...
@@ -58,13 +58,9 @@ int readString(FILE *fp, char** target) {
len
+=
2
;
len
+=
2
;
*
target
=
(
char
*
)
malloc
(
len
);
*
target
=
(
char
*
)
malloc
(
len
);
if
(
!
readBytes
(
fp
,
*
target
,
len
))
{
if
(
!
readBytes
(
fp
,
*
target
,
len
))
{
free
(
*
target
);
*
target
=
NULL
;
return
0
;
return
0
;
}
}
if
(
!
consumeNewline
(
*
target
+
len
-
2
))
{
if
(
!
consumeNewline
(
*
target
+
len
-
2
))
{
free
(
*
target
);
*
target
=
NULL
;
return
0
;
return
0
;
}
}
(
*
target
)[
len
-
2
]
=
'\0'
;
(
*
target
)[
len
-
2
]
=
'\0'
;
...
@@ -82,14 +78,10 @@ long process(FILE *fp) {
...
@@ -82,14 +78,10 @@ long process(FILE *fp) {
while
(
1
)
{
while
(
1
)
{
if
(
!
multi
)
pos
=
ftell
(
fp
);
if
(
!
multi
)
pos
=
ftell
(
fp
);
if
(
!
readArgc
(
fp
,
&
argc
))
{
if
(
!
readArgc
(
fp
,
&
argc
))
break
;
break
;
}
for
(
i
=
0
;
i
<
argc
;
i
++
)
{
for
(
i
=
0
;
i
<
argc
;
i
++
)
{
if
(
!
readString
(
fp
,
&
str
))
{
if
(
!
readString
(
fp
,
&
str
))
break
;
break
;
}
if
(
i
==
0
)
{
if
(
i
==
0
)
{
if
(
strcasecmp
(
str
,
"multi"
)
==
0
)
{
if
(
strcasecmp
(
str
,
"multi"
)
==
0
)
{
if
(
multi
++
)
{
if
(
multi
++
)
{
...
@@ -106,7 +98,7 @@ long process(FILE *fp) {
...
@@ -106,7 +98,7 @@ long process(FILE *fp) {
free
(
str
);
free
(
str
);
}
}
/*
Check if loop was
finish
ed
*/
/*
Stop if the loop did not
finish */
if
(
i
<
argc
)
{
if
(
i
<
argc
)
{
if
(
str
)
free
(
str
);
if
(
str
)
free
(
str
);
break
;
break
;
...
@@ -116,11 +108,9 @@ long process(FILE *fp) {
...
@@ -116,11 +108,9 @@ long process(FILE *fp) {
if
(
feof
(
fp
)
&&
multi
&&
strlen
(
error
)
==
0
)
{
if
(
feof
(
fp
)
&&
multi
&&
strlen
(
error
)
==
0
)
{
ERROR
(
"Reached EOF before reading EXEC for MULTI"
);
ERROR
(
"Reached EOF before reading EXEC for MULTI"
);
}
}
if
(
strlen
(
error
)
>
0
)
{
if
(
strlen
(
error
)
>
0
)
{
printf
(
"%s
\n
"
,
error
);
printf
(
"%s
\n
"
,
error
);
}
}
return
pos
;
return
pos
;
}
}
...
...
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