Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix off by one error #677

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion PackageInfo.g
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ Persons := [
IsAuthor := false,
IsMaintainer := false,
Email := "[email protected]",
WWWHome := "https://www.morphism.de/~markusp/"),
WWWHome := "https://markusp.morphism.de/"),

rec(
LastName := "Pointon",
Expand Down
14 changes: 10 additions & 4 deletions src/homos.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ extern Obj LargestMovedPointPerms;

static Obj GAP_FUNC; // Variable to hold a GAP level hook function

static Obj (*HOOK)(void*, // HOOK function applied to every homo found
static Obj (*HOOK)(void*, // HOOK function applied to every homo found
const uint16_t,
const uint16_t*);
static void* USER_PARAM; // a USER_PARAM for the hook
Expand Down Expand Up @@ -1642,14 +1642,20 @@ static bool init_data_from_args(Obj digraph1_obj,
uint16_t calculated_max_verts =
MAX(DigraphNrVertices(digraph1_obj), DigraphNrVertices(digraph2_obj));
if (!homos_data_initialized
|| (calculated_max_verts > HOMOS_STRUCTURE_SIZE)) {
|| (calculated_max_verts >= HOMOS_STRUCTURE_SIZE)) {
FuncDIGRAPHS_FREE_HOMOS_DATA(0L);
homos_data_initialized = true;

// Rather arbitrary, but we multiply by 1.2 to avoid
// n = 1,2,3,4,5... causing constant reallocation
HOMOS_STRUCTURE_SIZE = calculated_max_verts + calculated_max_verts / 5;
// srand(time(0));
HOMOS_STRUCTURE_SIZE =
(calculated_max_verts + calculated_max_verts / 5) + 1;
// The previous line includes "+ 1" because below we do:
// "BLISS_GRAPH[3 * PERM_DEGREE]" but we only allocate bliss graphs in
// BLISS_GRAPH up to but not including 3 * HOMOS_STRUCTURE_SIZE. So if
// PERM_DEGREE = (# nodes in digraph2) = HOMOS_STRUCTURE_SIZE (the
// first equality always holds, the second if # nodes in digraph2 >
// # nodes in digraph1), then this is out of bounds.
#ifdef DIGRAPHS_ENABLE_STATS
STATS = safe_malloc(sizeof(HomoStats));
#endif
Expand Down
Loading