bugfixingV1

This commit is contained in:
Tobias Busch 2025-12-15 11:52:02 +01:00
parent ef6946fa0b
commit d27b558ddc
11 changed files with 19 additions and 21 deletions

View File

@ -14,13 +14,14 @@ static TreeNode *createNode(const void *data, size_t dataSize)
if (!newNode)
return NULL;
newNode->data = malloc(dataSize);
newNode->data = malloc(dataSize); //hier kein malloc -> nur data pointer?
if (!newNode->data)
{
free(newNode);
return 0;
}
newNode->data = data;
//newNode->data = data;
memcpy(newNode->data, data, dataSize);
return newNode;
}
@ -125,12 +126,10 @@ void clearTree(TreeNode *root)
// Returns the number of entries in the tree given by root.
unsigned int treeSize(const TreeNode* root)
{
unsigned int treeSize = 0;
TreeNode* data = nextTreeData(root);
while (data != NULL)
{
treeSize++;
data = nextTreeData(NULL);
if (root == NULL) {
return 0;
}
return treeSize;
return 1 + treeSize(root->left) + treeSize(root->right);
/// ich + alles links + alles rechts
}

View File

@ -5,18 +5,19 @@
typedef int (*CompareFctType)(const void *arg1, const void *arg2); //ganz zahlen
void foo(void* ptr) {
/*void foo(void* ptr) {
unsigned int* casted_pointer = ptr;
unsigned int** a = &casted_pointer; //pointer pointer
unsigned int* b = casted_pointer; //pointer
unsigned int c = *casted_pointer; //wert
}
*/
typedef struct node
typedef struct nodeT
{
void *data;
struct node *left;
struct node *right;
struct nodeT *left;
struct nodeT *right;
} TreeNode;
// Adds a copy of data's pointer destination to the tree using compareFct for ordering. Accepts duplicates

BIN
bintree.o Normal file

Binary file not shown.

BIN
doble Executable file

Binary file not shown.

BIN
highscore.o Normal file

Binary file not shown.

View File

@ -1,5 +1,3 @@
player2;17901
player_name2;14920
player2;14844
player_name;6977
player1;3999
à«;1
;0
À«;0

BIN
main.o Normal file

Binary file not shown.

View File

@ -5,7 +5,7 @@
#include "numbers.h"
#include "bintree.h"
CompareFctType compareFct(const void *arg1, const void *arg2)
int compareFct(const void *arg1, const void *arg2)
{
const unsigned int *entry1 = arg1;
const unsigned int *entry2 = arg2;
@ -56,8 +56,8 @@ unsigned int *createNumbers(unsigned int len)
clearTree(numbers);
int duplicatePosition1 = rand() % len;
int duplicatePosition2 = rand() % len;
unsigned int duplicatePosition1 = rand() % len;
unsigned int duplicatePosition2 = rand() % len;
while (duplicatePosition2 == duplicatePosition1)
{

BIN
numbers.o Normal file

Binary file not shown.

BIN
stack.o

Binary file not shown.

BIN
timer.o Normal file

Binary file not shown.