Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Move the fossil_strdup() implementation from import.c over to util.c where it belongs. Add a new fossil_strdup_nn() that mimics the behavior of mprintf("%s",...), only faster. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
0c9dff644ec0bc70bb9ef3a34ff83b03 |
| User & Date: | drh 2024-08-23 13:00:08.266 |
Context
|
2024-08-23
| ||
| 13:05 | Fix missing "return" in the new fossil_strdup_nn() routine from the previous check-in. check-in: a04d18198d user: drh tags: trunk | |
| 13:00 | Move the fossil_strdup() implementation from import.c over to util.c where it belongs. Add a new fossil_strdup_nn() that mimics the behavior of mprintf("%s",...), only faster. check-in: 0c9dff644e user: drh tags: trunk | |
| 10:41 | Add documentation about internal data structures (specifically, the CONFIG table entries used and what they mean) on the login-group setup page. check-in: 5bb4cee5ec user: drh tags: trunk | |
Changes
Changes to src/db.c.
| ︙ | ︙ | |||
894 895 896 897 898 899 900 |
const char *db_column_name(Stmt *pStmt, int N){
return (char*)sqlite3_column_name(pStmt->pStmt, N);
}
int db_column_count(Stmt *pStmt){
return sqlite3_column_count(pStmt->pStmt);
}
char *db_column_malloc(Stmt *pStmt, int N){
| | | 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 |
const char *db_column_name(Stmt *pStmt, int N){
return (char*)sqlite3_column_name(pStmt->pStmt, N);
}
int db_column_count(Stmt *pStmt){
return sqlite3_column_count(pStmt->pStmt);
}
char *db_column_malloc(Stmt *pStmt, int N){
return fossil_strdup_nn(db_column_text(pStmt, N));
}
void db_column_blob(Stmt *pStmt, int N, Blob *pBlob){
blob_append(pBlob, sqlite3_column_blob(pStmt->pStmt, N),
sqlite3_column_bytes(pStmt->pStmt, N));
}
Blob db_column_text_as_blob(Stmt *pStmt, int N){
Blob x;
|
| ︙ | ︙ | |||
1190 1191 1192 1193 1194 1195 1196 |
va_list ap;
Stmt s;
char *z;
va_start(ap, zSql);
db_vprepare(&s, 0, zSql, ap);
va_end(ap);
if( db_step(&s)==SQLITE_ROW ){
| | < < | | 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 |
va_list ap;
Stmt s;
char *z;
va_start(ap, zSql);
db_vprepare(&s, 0, zSql, ap);
va_end(ap);
if( db_step(&s)==SQLITE_ROW ){
z = fossil_strdup_nn((const char*)sqlite3_column_text(s.pStmt, 0));
}else{
z = fossil_strdup(zDefault);
}
db_finalize(&s);
return z;
}
/*
** Initialize a new database file with the given schema. If anything
|
| ︙ | ︙ | |||
2532 2533 2534 2535 2536 2537 2538 |
for(i=0; i<count(aDbName); i++){
sqlite3_snprintf(sizeof(zPwd)-n, &zPwd[n], "/%s", aDbName[i]);
if( isValidLocalDb(zPwd) ){
if( db_open_config(0, 1)==0 ){
return 0; /* Configuration could not be opened */
}
/* Found a valid check-out database file */
| | | 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 |
for(i=0; i<count(aDbName); i++){
sqlite3_snprintf(sizeof(zPwd)-n, &zPwd[n], "/%s", aDbName[i]);
if( isValidLocalDb(zPwd) ){
if( db_open_config(0, 1)==0 ){
return 0; /* Configuration could not be opened */
}
/* Found a valid check-out database file */
g.zLocalDbName = fossil_strdup(zPwd);
zPwd[n] = 0;
while( n>0 && zPwd[n-1]=='/' ){
n--;
zPwd[n] = 0;
}
g.zLocalRoot = mprintf("%s/", zPwd);
g.localOpen = 1;
|
| ︙ | ︙ | |||
2668 2669 2670 2671 2672 2673 2674 |
}else{
#ifdef FOSSIL_ENABLE_JSON
g.json.resultCode = FSL_JSON_E_DB_NOT_VALID;
#endif
fossil_fatal("not a valid repository: %s", zDbName);
}
}
| | | 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 |
}else{
#ifdef FOSSIL_ENABLE_JSON
g.json.resultCode = FSL_JSON_E_DB_NOT_VALID;
#endif
fossil_fatal("not a valid repository: %s", zDbName);
}
}
g.zRepositoryName = fossil_strdup(zDbName);
db_open_or_attach(g.zRepositoryName, "repository");
g.repositoryOpen = 1;
sqlite3_file_control(g.db, "repository", SQLITE_FCNTL_DATA_VERSION,
&g.iRepoDataVers);
/* Cache "allow-symlinks" option, because we'll need it on every stat call */
g.allowSymlinks = db_get_boolean("allow-symlinks",0);
|
| ︙ | ︙ | |||
3508 3509 3510 3511 3512 3513 3514 |
char *zOut;
if( g.perm.RdAddr ){
zOut = db_text(0, "SELECT content FROM concealed WHERE hash=%Q", zKey);
}else{
zOut = 0;
}
if( zOut==0 ){
| | | 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 |
char *zOut;
if( g.perm.RdAddr ){
zOut = db_text(0, "SELECT content FROM concealed WHERE hash=%Q", zKey);
}else{
zOut = 0;
}
if( zOut==0 ){
zOut = fossil_strdup_nn(zKey);
}
return zOut;
}
/*
** Return true if the string zVal represents "true" (or "false").
*/
|
| ︙ | ︙ |
Changes to src/import.c.
| ︙ | ︙ | |||
71 72 73 74 75 76 77 | int nFileAlloc; /* Number of slots in aFile[] */ ImportFile *aFile; /* Information about files in a commit */ ImportFile *pInlineFile; /* File marked "inline" */ int fromLoaded; /* True zFrom content loaded into aFile[] */ int tagCommit; /* True if the commit adds a tag */ } gg; | < < < < < < < < < < < < < < < < < < < < < < | 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
int nFileAlloc; /* Number of slots in aFile[] */
ImportFile *aFile; /* Information about files in a commit */
ImportFile *pInlineFile; /* File marked "inline" */
int fromLoaded; /* True zFrom content loaded into aFile[] */
int tagCommit; /* True if the commit adds a tag */
} gg;
/*
** A no-op "xFinish" method
*/
static void finish_noop(void){}
/*
** Deallocate the state information.
|
| ︙ | ︙ |
Changes to src/util.c.
| ︙ | ︙ | |||
146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
if( munmap(p, n) ){
fossil_panic("munmap failed: %d\n", errno);
}
#else
fossil_free(p);
#endif
}
/*
** Translate every upper-case character in the input string into
** its equivalent lower-case.
*/
char *fossil_strtolwr(char *zIn){
char *zStart = zIn;
| > > > > > > > > > > > > > > > > > > > > > > | 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
if( munmap(p, n) ){
fossil_panic("munmap failed: %d\n", errno);
}
#else
fossil_free(p);
#endif
}
/*
** Duplicate a string.
*/
char *fossil_strndup(const char *zOrig, ssize_t len){
char *z = 0;
if( zOrig ){
if( len<0 ) len = strlen(zOrig);
z = fossil_malloc( len+1 );
memcpy(z, zOrig, len);
z[len] = 0;
}
return z;
}
char *fossil_strdup(const char *zOrig){
return fossil_strndup(zOrig, -1);
}
char *fossil_strdup_nn(const char *zOrig){
if( zOrig==0 ) fossil_strndup("", 0);
return fossil_strndup(zOrig, -1);
}
/*
** Translate every upper-case character in the input string into
** its equivalent lower-case.
*/
char *fossil_strtolwr(char *zIn){
char *zStart = zIn;
|
| ︙ | ︙ |