void initialize_sieve_of_eratosthenes(int n) { if (primesTable.table == NULL) { primesTable.size = n; primesTable.table = malloc(n * sizeof(bool)); memset(primesTable.table, true, primesTable.size); } else { int original_size = primesTable.size; bool *original_table = primesTable.table;
void initialize_sieve_of_eratosthenes(int n) {
if (primesTable.table == NULL) {
primesTable.size = n;
primesTable.table = malloc(n * sizeof(bool));
memset(primesTable.table, true, primesTable.size);
} else {
int original_size = primesTable.size;
bool *original_table = primesTable.table;
primesTable.size = n;
primesTable.table = malloc(n * sizeof(bool));
memset(primesTable.table, true, primesTable.size);
memcpy(primesTable.table, original_table, original_size * sizeof(bool));
free(original_table);
}
int main() {
HASH_CONS_TABLE hc = malloc(sizeof(struct hash_cons_table));
if (hc == NULL)
{
fprintf(stderr, "Memory Allocation of HASH_CONS_TABLE hc error in main().\nExiting Program.");
return(EXIT_FAILURE);
}
hc->hashf = hash;
hc->equalf = equal;
hc->size = 0;
DUMMY create_dummy(int key) {
DUMMY dummy = malloc(sizeof(dummy));
if (dummy == NULL)
{
fprintf(stderr, "Memory Allocation error in create_dummy().\nExiting Program.");
exit(EXIT_FAILURE);
}
dummy->key = key;
return dummy;
}
void initialize_sieve_of_eratosthenes(int n) { if (primesTable.table == NULL) { primesTable.size = n; primesTable.table = malloc(n * sizeof(bool)); if (primesTable.table == NULL) { fprintf(stderr, "Memory Allocation of primesTable.table error in initialize_sieve_of_eratosthenes().\nExiting Program."); exit(EXIT_FAILURE); } memset(primesTable.table, true, primesTable.size); } else { int original_size = primesTable.size; bool *original_table = primesTable.table;
int main() {
HASH_CONS_TABLE hc = malloc(sizeof(struct hash_cons_table));
if (hc == NULL)
{
fprintf(stderr, "Memory Allocation of HASH_CONS_TABLE hc error in main().\nExiting Program.");
return(EXIT_FAILURE);
}
hc->hashf = hash;
hc->equalf = equal;
hc->size = 0;
DUMMY create_dummy(int key) {
DUMMY dummy = malloc(sizeof(dummy));
if (dummy == NULL)
{
fprintf(stderr, "Memory Allocation error in create_dummy().\nExiting Program.");
exit(EXIT_FAILURE);
}
dummy->key = key;
return dummy;
}
void initialize_sieve_of_eratosthenes(int n) {
if (primesTable.table == NULL) {
primesTable.size = n;
primesTable.table = malloc(n * sizeof(bool));
if (primesTable.table == NULL)
{
fprintf(stderr, "Memory Allocation of primesTable.table error in initialize_sieve_of_eratosthenes().\nExiting Program.");
exit(EXIT_FAILURE);
}
memset(primesTable.table, true, primesTable.size);
} else {
int original_size = primesTable.size;
bool *original_table = primesTable.table;
primesTable.size = n;
primesTable.table = malloc(n * sizeof(bool));
if (primesTable.table == NULL)
{
fprintf(stderr, "Memory Allocation of primesTable.table error in initialize_sieve_of_eratosthenes().\nExiting Program.");
exit(EXIT_FAILURE);
}
memset(primesTable.table, true, primesTable.size);
memcpy(primesTable.table, original_table, original_size * sizeof(bool));
free(original_table);
}