summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: dd86fdf)
raw | patch | inline | side by side (parent: dd86fdf)
author | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Wed, 30 May 2007 19:56:34 +0000 (19:56 +0000) | ||
committer | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Wed, 30 May 2007 19:56:34 +0000 (19:56 +0000) |
src/rrd_open.c | patch | blob | history | |
src/rrd_update.c | patch | blob | history |
diff --git a/src/rrd_open.c b/src/rrd_open.c
index 238c052ae3e168f50d5251c47402dd7cc07fc935..92369fd01c094bb560e77f6ad7d64f388059a04b 100644 (file)
--- a/src/rrd_open.c
+++ b/src/rrd_open.c
#endif /* DEBUG */
#ifdef USE_MADVISE
-#ifdef ONE_PAGE
+# ifdef ONE_PAGE
/* Keep headers around, round up to next page boundary. */
ret =
PAGE_ALIGN(rrd_file->header_len % _page_size + rrd_file->header_len);
if (rrd_file->file_len > ret)
_madvise(rrd_file->file_start + ret,
rrd_file->file_len - ret, MADV_DONTNEED);
-#else
+# else
/* ignoring errors from RRDs that are smaller then the file_len+rounding */
_madvise(rrd_file->file_start + PAGE_ALIGN_DOWN(rrd_file->header_len),
rrd_file->file_len - PAGE_ALIGN(rrd_file->header_len),
MADV_DONTNEED);
-#endif
+# endif
#endif
#ifdef HAVE_MMAP
ret = munmap(rrd_file->file_start, rrd_file->file_len);
/* read count bytes into buffer buf, starting at rrd_file->pos.
* Returns the number of bytes read. */
-ssize_t rrd_read(
+inline ssize_t rrd_read(
rrd_file_t *rrd_file,
void *buf,
size_t count)
{
#ifdef HAVE_MMAP
- buf = memmove(buf, rrd_file->file_start + rrd_file->pos, count);
+ buf = memcpy(buf, rrd_file->file_start + rrd_file->pos, count);
rrd_file->pos += count; /* mimmic read() semantics */
return count;
#else
* rrd_file->pos of rrd_file->fd.
* Returns the number of bytes written. */
-ssize_t rrd_write(
+inline ssize_t rrd_write(
rrd_file_t *rrd_file,
const void *buf,
size_t count)
{
#ifdef HAVE_MMAP
- memmove(rrd_file->file_start + rrd_file->pos, buf, count);
+ memcpy(rrd_file->file_start + rrd_file->pos, buf, count);
+ rrd_file->pos += count;
return count; /* mimmic write() semantics */
#else
- return write(rrd_file->fd, buf, count);
+ ssize_t _sz = write(rrd_file->fd, buf, count);
+ if (_sz > 0)
+ rrd_file->pos += _sz;
+ return _sz;
#endif
}
diff --git a/src/rrd_update.c b/src/rrd_update.c
index 18db8e7ceb02c5e0cba86f12aa9bb6bc330e8ba8..b114c9bfa61fa87a1e34488c465a8dd8386311e4 100644 (file)
--- a/src/rrd_update.c
+++ b/src/rrd_update.c
}
}
-static info_t *write_RRA_row(
+static inline info_t *write_RRA_row(
rrd_file_t *rrd_file,
rrd_t *rrd,
unsigned long rra_idx,
if (rrd_write
(rrd_file,
&(rrd->cdp_prep[cdp_idx].scratch[CDP_scratch_idx].u_val),
- sizeof(rrd_value_t) * 1) != sizeof(rrd_value_t) * 1) {
+ sizeof(rrd_value_t)) != sizeof(rrd_value_t)) {
rrd_set_error("writing rrd: %s", rrd_strerror(errno));
return 0;
}