mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-08 14:02:16 +03:00
Add and use the internal sqlite3DbSpanDup() interface.
FossilOrigin-Name: a8e1545cb7aacb6a26a8c92a3ad4a3d584d150c3a00d2828c8adbb1ee19fcb6d
This commit is contained in:
13
src/malloc.c
13
src/malloc.c
@@ -627,6 +627,19 @@ char *sqlite3DbStrNDup(sqlite3 *db, const char *z, u64 n){
|
||||
return zNew;
|
||||
}
|
||||
|
||||
/*
|
||||
** The text between zStart and zEnd represents a phrase within a larger
|
||||
** SQL statement. Make a copy of this phrase in space obtained form
|
||||
** sqlite3DbMalloc(). Omit leading and trailing whitespace.
|
||||
*/
|
||||
char *sqlite3DbSpanDup(sqlite3 *db, const char *zStart, const char *zEnd){
|
||||
int n;
|
||||
while( sqlite3Isspace(zStart[0]) ) zStart++;
|
||||
n = (int)(zEnd - zStart);
|
||||
while( n>0 && sqlite3Isspace(zStart[n-1]) ) n--;
|
||||
return sqlite3DbStrNDup(db, zStart, n);
|
||||
}
|
||||
|
||||
/*
|
||||
** Free any prior content in *pz and replace it with a copy of zNew.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user