aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/htab.h2
-rw-r--r--src/htab.c18
-rw-r--r--src/jobs.c6
-rw-r--r--src/queue.c4
4 files changed, 14 insertions, 16 deletions
diff --git a/include/htab.h b/include/htab.h
index 70a0893..7ea1730 100644
--- a/include/htab.h
+++ b/include/htab.h
@@ -9,7 +9,7 @@ struct htab {
};
void htab_free(struct htab *htab);
-int htab_init(struct htab **htab);
+int htab_init(size_t nel, struct htab **htab);
int htab_delete(struct htab *htab, const char *key);
int htab_enter(struct htab *htab, const char *key, void *data);
int htab_search(struct htab *htab, char *key, ENTRY **ep);
diff --git a/src/htab.c b/src/htab.c
index dde8430..066d761 100644
--- a/src/htab.c
+++ b/src/htab.c
@@ -1,7 +1,7 @@
-/* since hsearch_r does not support deletions dirctly, this is an abstraction on
- * top of it with support for deletions, for this to work properly we have to
- * strdup the key, this is not a big issue for 100k drv_path strings, it's
- * either this or pulling in a external library
+/* since hsearch_r does not support deletions dirctly (gotta go fast), this is
+ * an abstraction on top of it with support for deletions, for this to work
+ * properly we have to strdup the key, this is not a big issue for 100k drv_path
+ * strings, it's either this or pulling in an external library
*/
#include <errno.h>
@@ -11,8 +11,6 @@
#include "htab.h"
#include "util.h"
-#define MAX_NIX_PKG_COUNT 200000
-
static int htab_keys_insert(struct htab *htab, char *key);
static int htab_keys_insert(struct htab *htab, char *key)
@@ -97,7 +95,7 @@ int htab_delete(struct htab *htab, const char *key)
return htab_enter(htab, key, NULL);
}
-int htab_init(struct htab **htab)
+int htab_init(size_t nel, struct htab **htab)
{
int ret;
struct htab *h;
@@ -115,7 +113,7 @@ int htab_init(struct htab **htab)
goto out_free_h;
}
- ret = hcreate_r(MAX_NIX_PKG_COUNT, h->table);
+ ret = hcreate_r(nel, h->table);
if (ret == 0) {
print_err("%s", strerror(errno));
ret = -errno;
@@ -143,8 +141,10 @@ void htab_free(struct htab *htab)
{
for (size_t i = 0; i < htab->key_filled; i++)
free(htab->keys[i]);
-
free(htab->keys);
+
+ hdestroy_r(htab->table);
free(htab->table);
+
free(htab);
}
diff --git a/src/jobs.c b/src/jobs.c
index 3e38b07..6f06ef9 100644
--- a/src/jobs.c
+++ b/src/jobs.c
@@ -278,8 +278,8 @@ void job_free(struct job *job)
if (job == NULL)
return;
- /* deps_filled will be decremented by recusrive call to the job_free
- * see job_deps_list_rm() in the next for loop */
+ /* deps_filled will be decremented by recusrive call to job_free()
+ * itself, see job_deps_list_rm() in the next for loop */
while (job->deps_filled)
job_free(*job->deps);
free(job->deps);
@@ -369,7 +369,7 @@ int jobs_init(FILE **stream)
char *const args[] = {
"nix-eval-jobs",
"--flake",
- "github:NixOS/nixpkgs#legacyPackages.x86_64-linux.python310Packages",
+ "github:sinanmohd/evanix#packages.x86_64-linux",
NULL,
};
diff --git a/src/queue.c b/src/queue.c
index b02474e..d895ebc 100644
--- a/src/queue.c
+++ b/src/queue.c
@@ -111,8 +111,6 @@ static int queue_htab_job_merge(struct job **job, struct htab *htab)
ENTRY *ep;
int ret;
- // e.key = (*job)->drv_path;
- // ret = hsearch_r(e, FIND, &ep, htab);
ret = htab_search(htab, (*job)->drv_path, &ep);
if (ret < 0) {
return ret;
@@ -229,7 +227,7 @@ int queue_thread_new(struct queue_thread **queue_thread, FILE *stream)
goto out_free_queue;
}
- ret = htab_init(&qt->queue->htab);
+ ret = htab_init(MAX_NIX_PKG_COUNT, &qt->queue->htab);
if (ret < 0)
goto out_free_sem;