Format source code, add .exrc

This commit is contained in:
Jordan Bancino 2022-11-23 14:56:31 +00:00
parent 84f311ae09
commit 7544a97c7d
4 changed files with 30 additions and 20 deletions

2
.exrc Normal file
View File

@ -0,0 +1,2 @@
set tabstop=4
set expandtab

View File

@ -407,10 +407,10 @@ DbLockFromArr(Db * db, Array * args)
{ {
db->leastRecent = ref->next; db->leastRecent = ref->next;
} }
else else
{ {
ref->prev->next = ref->next; ref->prev->next = ref->next;
} }
ref->prev = db->mostRecent; ref->prev = db->mostRecent;
ref->next = NULL; ref->next = NULL;
@ -423,6 +423,9 @@ DbLockFromArr(Db * db, Array * args)
} }
else else
{ {
Array *name = ArrayCreate();
size_t i;
/* Not in cache; load from disk */ /* Not in cache; load from disk */
ref = Malloc(sizeof(DbRef)); ref = Malloc(sizeof(DbRef));
@ -448,7 +451,12 @@ DbLockFromArr(Db * db, Array * args)
ref->ts = UtilServerTs(); ref->ts = UtilServerTs();
ref->size = DbComputeSize(ref->json); ref->size = DbComputeSize(ref->json);
ref->name = ArrayDuplicate(args);
for (i = 0; i < ArraySize(args); i++)
{
ArrayAdd(name, UtilStringDuplicate(ArrayGet(args, i)));
}
ref->name = name;
HashMapSet(db->cache, hash, ref); HashMapSet(db->cache, hash, ref);
db->cacheSize += ref->size; db->cacheSize += ref->size;
@ -512,7 +520,7 @@ DbCreate(Db * db, size_t nArgs,...)
return NULL; return NULL;
} }
Free(dir); Free(dir);
fp = fopen(file, "w"); fp = fopen(file, "w");
Free(file); Free(file);
@ -564,10 +572,10 @@ DbUnlock(Db * db, DbRef * ref)
rewind(ref->fp); rewind(ref->fp);
if (ftruncate(fileno(ref->fp), 0) < 0) if (ftruncate(fileno(ref->fp), 0) < 0)
{ {
pthread_mutex_unlock(&db->lock); pthread_mutex_unlock(&db->lock);
return 0; return 0;
} }
JsonEncode(ref->json, ref->fp); JsonEncode(ref->json, ref->fp);

View File

@ -205,12 +205,12 @@ main(int argc, char **argv)
goto finish; goto finish;
} }
if (!configArg) if (!configArg)
{ {
Log(lc, LOG_ERROR, "No configuration file specified."); Log(lc, LOG_ERROR, "No configuration file specified.");
exit = EXIT_FAILURE; exit = EXIT_FAILURE;
goto finish; goto finish;
} }
else if (strcmp(configArg, "-") == 0) else if (strcmp(configArg, "-") == 0)
{ {
configFile = stdin; configFile = stdin;

View File

@ -235,10 +235,10 @@ UtilStringConcat(char *str1, char *str2)
{ {
strcpy(ret, str2); strcpy(ret, str2);
} }
else else
{ {
strcpy(ret, ""); strcpy(ret, "");
} }
} }
return ret; return ret;