Skip to content

Commit

Permalink
more prefix stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
arminbiere committed Jan 23, 2025
1 parent 25fb019 commit acbbba8
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/allocate.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,18 @@ void *kissat_realloc (kissat *solver, void *p, size_t old_bytes,
return 0;
}
dec_bytes (solver, old_bytes);
#ifdef LOGGING
if (GET_OPTION (log) > 3)
kissat_begin_logging (solver, LOGPREFIX, "realloc (%p[%zu, %zu) = ", p,
old_bytes, new_bytes);
#endif
void *res = realloc (p, new_bytes);
LOG4 ("realloc (%p[%zu], %zu) = %p", p, old_bytes, new_bytes, res);
#ifdef LOGGING
if (GET_OPTION (log) > 3) {
printf ("%p", res);
kissat_end_logging ();
}
#endif
if (new_bytes && !res)
kissat_fatal ("out-of-memory reallocating from %zu to %zu bytes",
old_bytes, new_bytes);
Expand Down
2 changes: 1 addition & 1 deletion src/congruence.c
Original file line number Diff line number Diff line change
Expand Up @@ -2804,7 +2804,7 @@ static clause *find_large_xor_side_clause (closure *closure,
break;
}
}
if (found == size_lits && !c->garbage) {
if (found < UINT_MAX && !c->garbage) {
res = c;
break;
}
Expand Down
10 changes: 10 additions & 0 deletions src/logging.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ static void end_logging (void) {
fflush (stdout);
}

void kissat_begin_logging (kissat *solver, const char *prefix,
const char *fmt, ...) {
va_list ap;
va_start (ap, fmt);
begin_logging (solver, prefix, fmt, &ap);
va_end (ap);
}

void kissat_end_logging (void) { end_logging (); }

void kissat_log_msg (kissat *solver, const char *prefix, const char *fmt,
...) {
va_list ap;
Expand Down
8 changes: 8 additions & 0 deletions src/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,20 @@
#include "reference.h"
#include "watch.h"

#include <stdarg.h>

// clang-format off

const char * kissat_log_lit (kissat *, unsigned lit);
const char * kissat_log_var (kissat *, unsigned idx);
const char * kissat_log_repr (kissat *, unsigned lit, const unsigned *);

void kissat_begin_logging (kissat *, const char *prefix,
const char *fmt, ...)
ATTRIBUTE_FORMAT (3, 4);

void kissat_end_logging (void);

void kissat_log_msg (kissat *, const char*, const char *fmt, ...)
ATTRIBUTE_FORMAT (3, 4);

Expand Down

0 comments on commit acbbba8

Please sign in to comment.