Compare commits

..

No commits in common. "master" and "alignment" have entirely different histories.

7 changed files with 8 additions and 143 deletions

View file

@ -21,8 +21,6 @@ are not even initialized to a default value.
- Make `HttpRouter` decode path parts before matching them on regular expressions.
- Fixed a bug in `ArraySort()` that would crash programs if the passed array has no
elements.
- Adds `Db[OP]Args` functions that are equivalent to their `Db[OP]` counter parts, but
uses an array of string instead of variadic arguments.
## v0.4.0

View file

@ -119,13 +119,6 @@ extern void DbMaxCacheSet(Db *, size_t);
*/
extern DbRef * DbCreate(Db *, size_t,...);
/**
* Behaves like
* .Fn DbCreate ,
* but with an array of strings instead of variadic arguments.
*/
extern DbRef * DbCreateArgs(Db *, Array *);
/**
* Lock an existing object in the database. This function will fail
* if the object does not exist. It takes a variable number of C
@ -136,13 +129,6 @@ extern DbRef * DbCreateArgs(Db *, Array *);
*/
extern DbRef * DbLock(Db *, size_t,...);
/**
* Behaves like
* .Fn DbLock ,
* but with an array of strings instead of variadic arguments.
*/
extern DbRef * DbLockArgs(Db *, Array *);
/**
* Behaves like
* .Fn DbLock ,
@ -152,13 +138,6 @@ extern DbRef * DbLockArgs(Db *, Array *);
*/
extern DbRef * DbLockIntent(Db *, DbHint, size_t,...);
/**
* Behaves like
* .Fn DbLockIntent ,
* but with an array of strings instead of variadic arguments.
*/
extern DbRef * DbLockIntentArgs(Db *, DbHint, Array *);
/**
* Immediately and permanently remove an object from the database.
* This function assumes the object is not locked, otherwise undefined
@ -166,13 +145,6 @@ extern DbRef * DbLockIntentArgs(Db *, DbHint, Array *);
*/
extern bool DbDelete(Db *, size_t,...);
/**
* Behaves like
* .Fn DbDelete ,
* but with an array of strings instead of variadic arguments.
*/
extern bool DbDeleteArgs(Db *, Array *);
/**
* Unlock an object and return it back to the database. This function
* immediately syncs the object to the filesystem. The cache is a
@ -190,13 +162,6 @@ extern bool DbUnlock(Db *, DbRef *);
*/
extern bool DbExists(Db *, size_t,...);
/**
* Behaves like
* .Fn DbExists ,
* but with an array of strings instead of variadic arguments.
*/
extern bool DbExistsArgs(Db *, Array *);
/**
* List all of the objects at a given path. Unlike the other varargs
* functions, this one does not take a path to a specific object; it
@ -209,13 +174,6 @@ extern bool DbExistsArgs(Db *, Array *);
*/
extern Array * DbList(Db *, size_t,...);
/**
* Behaves like
* .Fn DbList ,
* but with an array of strings instead of variadic arguments.
*/
extern Array * DbListArgs(Db *, Array *);
/**
* Free the list returned by
* .Fn DbListFree .

View file

@ -297,12 +297,6 @@ extern size_t JsonEncode(HashMap *, Stream *, int);
*/
extern HashMap * JsonDecode(Stream *);
/**
* Decodes a JSON value from thr current input strram and parse it
* into a JsonValue.
*/
extern JsonValue * JsonValueDecode(Stream *);
/**
* A convenience function that allows the caller to retrieve and
* arbitrarily deep keys within a JSON object. It takes a root JSON

View file

@ -262,16 +262,6 @@ DbClose(Db * db)
Free(db);
}
DbRef *
DbCreateArgs(Db * db, Array *args)
{
if (!args || !db || !db->create)
{
return NULL;
}
return db->create(db, args);
}
DbRef *
DbCreate(Db * db, size_t nArgs,...)
{
@ -293,22 +283,12 @@ DbCreate(Db * db, size_t nArgs,...)
return NULL;
}
ret = DbCreateArgs(db, args);
ret = db->create(db, args);
ArrayFree(args);
return ret;
}
bool
DbDeleteArgs(Db * db, Array *args)
{
if (!args || !db || !db->delete)
{
return false;
}
return db->delete(db, args);
}
bool
DbDelete(Db * db, size_t nArgs,...)
{
@ -325,22 +305,12 @@ DbDelete(Db * db, size_t nArgs,...)
args = ArrayFromVarArgs(nArgs, ap);
va_end(ap);
ret = DbDeleteArgs(db, args);
ret = db->delete(db, args);
ArrayFree(args);
return ret;
}
DbRef *
DbLockArgs(Db * db, Array *args)
{
if (!args || !db || !db->lockFunc)
{
return NULL;
}
return db->lockFunc(db, DB_HINT_WRITE, args);
}
DbRef *
DbLock(Db * db, size_t nArgs,...)
{
@ -348,11 +318,6 @@ DbLock(Db * db, size_t nArgs,...)
Array *args;
DbRef *ret;
if (!db)
{
return NULL;
}
va_start(ap, nArgs);
args = ArrayFromVarArgs(nArgs, ap);
va_end(ap);
@ -362,22 +327,13 @@ DbLock(Db * db, size_t nArgs,...)
return NULL;
}
ret = DbLockArgs(db, args);
ret = db->lockFunc(db, DB_HINT_WRITE, args);
ArrayFree(args);
return ret;
}
DbRef *
DbLockIntentArgs(Db * db, DbHint hint, Array *args)
{
if (!db || !args || !db->lockFunc)
{
return NULL;
}
return db->lockFunc(db, hint, args);
}
DbRef *
DbLockIntent(Db * db, DbHint hint, size_t nArgs,...)
{
@ -394,7 +350,7 @@ DbLockIntent(Db * db, DbHint hint, size_t nArgs,...)
return NULL;
}
ret = DbLockIntentArgs(db, hint, args);
ret = db->lockFunc(db, hint, args);
ArrayFree(args);
@ -412,16 +368,6 @@ DbUnlock(Db * db, DbRef * ref)
return db->unlock(db, ref);
}
bool
DbExistsArgs(Db * db, Array *args)
{
if (!args || !db || !db->exists)
{
return false;
}
return db->exists(db, args);
}
bool
DbExists(Db * db, size_t nArgs,...)
{
@ -442,21 +388,12 @@ DbExists(Db * db, size_t nArgs,...)
return false;
}
ret = DbExistsArgs(db, args);
ret = db->exists(db, args);
ArrayFree(args);
return ret;
}
Array *
DbListArgs(Db *db, Array *args)
{
if (!db || !args || !db->list)
{
return NULL;
}
return db->list(db, args);
}
Array *
DbList(Db * db, size_t nArgs,...)
{
@ -473,7 +410,7 @@ DbList(Db * db, size_t nArgs,...)
path = ArrayFromVarArgs(nArgs, ap);
va_end(ap);
result = DbListArgs(db, path);
result = db->list(db, path);
ArrayFree(path);
return result;

View file

@ -54,8 +54,7 @@ DbDirName(FlatDb * db, Array * args, size_t strip)
{
char *tmp;
char *sanitise = StrDuplicate(ArrayGet(args, i));
size_t len = strlen(sanitise);
for (j = 0; j < len; j++)
for (j = 0; j < strlen(sanitise); j++)
{
sanitise[j] = DbSanitiseChar(sanitise[j]);
}

View file

@ -128,9 +128,7 @@ LMDBKeyHead(MDB_val key)
return NULL;
}
/* Doing >= will lead to cases where it is sent straight to the
* start. Don't do that. */
while ((void *) (end - 1) > key.mv_data && *(end - 1))
while ((void *) (end - 1) >= key.mv_data && *(end - 1))
{
end--;
}

View file

@ -1348,25 +1348,6 @@ JsonDecode(Stream * stream)
return result;
}
JsonValue *
JsonValueDecode(Stream *stream)
{
JsonValue *result;
JsonParserState state;
state.stream = stream;
state.token = NULL;
JsonTokenSeek(&state);
result = JsonDecodeValue(&state);
if (state.token)
{
Free(state.token);
}
return result;
}
JsonValue *
JsonGet(HashMap * json, size_t nArgs,...)