From 4bf68b620434eb498bbcf1dfa9e12ec417c795e2 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Sun, 26 Jun 2011 11:16:47 +0200 Subject: [PATCH] Removed clashing of sopen in Windows. --- HISTORY | 1 + state.c | 4 ++-- util.c | 2 +- util.h | 6 +++--- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/HISTORY b/HISTORY index dd2b2e27..342d5117 100644 --- a/HISTORY +++ b/HISTORY @@ -10,6 +10,7 @@ SnapRAID HISTORY information for a potential GUI for SnapRAID. * Added a new "diff" command to print the list of changes detected at file level. +* Faster loading of content file. Approx 3 times faster. 1.4 2011/6 ========== diff --git a/state.c b/state.c index 942948c6..2eb78d43 100644 --- a/state.c +++ b/state.c @@ -70,7 +70,7 @@ void state_config(struct snapraid_state* state, const char* path, int verbose, i fflush(stderr); } - f = sopen(path); + f = sopen_read(path); if (!f) { if (errno == ENOENT) { fprintf(stderr, "No configuration file found at '%s'\n", path); @@ -305,7 +305,7 @@ void state_read(struct snapraid_state* state) } printf("Loading state from %s...\n", path); - f = sopen(path); + f = sopen_read(path); if (f != 0) { /* if openend stop the search */ break; diff --git a/util.c b/util.c index 44a8d9e6..7c63b096 100644 --- a/util.c +++ b/util.c @@ -86,7 +86,7 @@ char* strdechex(void* void_data, unsigned data_len, char* str) /****************************************************************************/ /* stream */ -STREAM* sopen(const char* file) +STREAM* sopen_read(const char* file) { STREAM* s = malloc_nofail(sizeof(STREAM)); diff --git a/util.h b/util.h index 86ae6b8f..6c0b4658 100644 --- a/util.h +++ b/util.h @@ -56,7 +56,7 @@ typedef struct stream STREAM; /** * Open a stream for reading. Like fopen(). */ -STREAM* sopen(const char* file); +STREAM* sopen_read(const char* file); /** * Close a stream. Like fclose(). @@ -79,7 +79,7 @@ static inline int sptrlookup(STREAM* s, int size) /** * Gets the current stream ptr. */ -unsigned char* sptrget(STREAM* s) +static inline unsigned char* sptrget(STREAM* s) { return s->pos; } @@ -87,7 +87,7 @@ unsigned char* sptrget(STREAM* s) /** * Set the current stream ptr. */ -void sptrset(STREAM* s, unsigned char* ptr) +static inline void sptrset(STREAM* s, unsigned char* ptr) { s->pos = ptr; }