Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
LSH
lsh
Commits
2f830289
Commit
2f830289
authored
Sep 22, 1998
by
Niels Möller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed the buffer rfilling.
Rev: src/write_buffer.c:1.7
parent
d868fb95
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
5 deletions
+12
-5
src/write_buffer.c
src/write_buffer.c
+12
-5
No files found.
src/write_buffer.c
View file @
2f830289
...
...
@@ -23,15 +23,20 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "xalloc.h"
#include "write_buffer.h"
#include "xalloc.h"
#include <assert.h>
static
int
do_write
(
struct
abstract_write
**
w
,
struct
lsh_string
*
packet
)
{
struct
write_buffer
*
closure
=
(
struct
write_buffer
*
)
*
w
;
struct
node
*
new
;
MDEBUG
(
closure
);
if
(
!
packet
->
length
)
{
lsh_string_free
(
packet
);
...
...
@@ -95,11 +100,11 @@ int write_buffer_pre_write(struct write_buffer *buffer)
if
(
buffer
->
partial
)
{
UINT32
partial_left
=
buffer
->
partial
->
length
-
buffer
->
pos
;
UINT32
buffer_left
=
2
*
buffer
->
block_size
-
length
;
UINT32
buffer_left
=
2
*
buffer
->
block_size
-
buffer
->
end
;
if
(
partial_left
<=
buffer_left
)
{
/* The rest of the partial packet fits in the buffer */
memcpy
(
buffer
->
buffer
+
length
,
memcpy
(
buffer
->
buffer
+
buffer
->
end
,
buffer
->
partial
->
data
+
buffer
->
pos
,
partial_left
);
...
...
@@ -111,13 +116,15 @@ int write_buffer_pre_write(struct write_buffer *buffer)
}
else
{
memcpy
(
buffer
->
buffer
+
length
,
memcpy
(
buffer
->
buffer
+
buffer
->
end
,
buffer
->
partial
->
data
+
buffer
->
pos
,
buffer_left
);
buffer
->
end
+=
buffer_left
;
length
+=
buffer_left
;
buffer
->
pos
+=
buffer_left
;
assert
(
length
>=
buffer
->
block_size
);
}
}
else
...
...
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