aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-12-11 19:23:19 +0000
committerDavid Robillard <d@drobilla.net>2011-12-11 19:23:19 +0000
commit5f7fed94b3ff74ede85ab9189221808543c4054b (patch)
tree8d71e9966066c039f22b150767b85a06d0cbf37b /src
parent258e987c94f61449e507f24d89613b1d41861487 (diff)
downloadserd-5f7fed94b3ff74ede85ab9189221808543c4054b.tar.gz
serd-5f7fed94b3ff74ede85ab9189221808543c4054b.tar.bz2
serd-5f7fed94b3ff74ede85ab9189221808543c4054b.zip
Align read buffer to page boundary if posix_memalign is available.
git-svn-id: http://svn.drobilla.net/serd/trunk@240 490d8e77-9747-427b-9fa3-0b8f29cee8a0
Diffstat (limited to 'src')
-rw-r--r--src/reader.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/reader.c b/src/reader.c
index d035448e..7c083dd6 100644
--- a/src/reader.c
+++ b/src/reader.c
@@ -14,6 +14,8 @@
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#define _POSIX_C_SOURCE 201112L /* for posix_memalign */
+
#include <assert.h>
#include <errno.h>
#include <stdarg.h>
@@ -24,6 +26,7 @@
#include <string.h>
#include "serd_internal.h"
+#include "serd-config.h"
#define NS_XSD "http://www.w3.org/2001/XMLSchema#"
#define NS_RDF "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
@@ -1530,11 +1533,15 @@ serd_reader_read_file_handle(SerdReader* me, FILE* file, const uint8_t* name)
{
const Cursor cur = { name, 1, 1 };
me->fd = file;
- me->read_buf = (uint8_t*)malloc(READ_BUF_LEN * 2);
me->read_head = 0;
me->cur = cur;
me->from_file = true;
me->eof = false;
+#ifdef HAVE_POSIX_MEMALIGN
+ posix_memalign((void**)&me->read_buf, 4096, READ_BUF_LEN * 2);
+#else
+ me->read_buf = (uint8_t*)malloc(READ_BUF_LEN * 2);
+#endif
/* Read into the second page of the buffer. Occasionally peek_string
will move the read_head to before this point when readahead causes