projects
/
ecparse.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
use different type for pointer arithmetic
[ecparse.git]
/
GrowingBuffer.cpp
diff --git
a/GrowingBuffer.cpp
b/GrowingBuffer.cpp
index
492f244
..
602084c
100644
(file)
--- a/
GrowingBuffer.cpp
+++ b/
GrowingBuffer.cpp
@@
-4,6
+4,7
@@
#include <stdlib.h>
#include <string.h>
#include <stdlib.h>
#include <string.h>
+#include <stddef.h>
#include "GrowingBuffer.h"
GrowingBuffer::GrowingBuffer(size_t initialSize) {
#include "GrowingBuffer.h"
GrowingBuffer::GrowingBuffer(size_t initialSize) {
@@
-37,7
+38,7
@@
void GrowingBuffer::seek(size_t position) {
void* GrowingBuffer::read(void* buffer, size_t length) {
size_t bytesToCopy = (length > (limit - position)) ? (limit - position) : length;
void* GrowingBuffer::read(void* buffer, size_t length) {
size_t bytesToCopy = (length > (limit - position)) ? (limit - position) : length;
- memcpy(buffer, (
char
*) data + position, bytesToCopy);
+ memcpy(buffer, (
ptrdiff_t
*) data + position, bytesToCopy);
position += bytesToCopy;
return buffer;
}
position += bytesToCopy;
return buffer;
}
@@
-53,7
+54,13
@@
void GrowingBuffer::write(const void* buffer, size_t length) {
free(data);
data = newData;
}
free(data);
data = newData;
}
- memcpy((char*) data + position, buffer, length);
+ memcpy((ptrdiff_t*) data + position, buffer, length);
+}
+
+void GrowingBuffer::cut() {
+ memcpy(data, (ptrdiff_t*) data + position, position);
+ limit = position;
+ position = 0;
}
void GrowingBuffer::truncate() {
}
void GrowingBuffer::truncate() {