some small fixes

This commit is contained in:
2025-06-13 05:51:53 +02:00
parent aa6cde55f4
commit 8e9cd18fa6
3 changed files with 170 additions and 202 deletions

View File

@@ -9,7 +9,7 @@
#define MIN_COUNT 10000
/*
* Usage: pipe dblp.xml to the programm or have it in the same folder as the program
* Usage: pipe dblp.xml to the program or have it in the same folder as the program
*/
void string_ncopy(char *dest, const char *src, size_t max_len) {
@@ -27,10 +27,12 @@ typedef struct person {
int count;
} person;
void newPerson(person *p, const char *name) {
person* newPerson(const char *name) {
person *p = (person *) malloc(sizeof(person));
string_ncopy(p->name, name, BUFFER_LENGTH);
p->count = 1;
p->next = NULL;
return p;
}
void sorted_name_insert(person **head, char *name) {
@@ -43,8 +45,7 @@ void sorted_name_insert(person **head, char *name) {
p = p->next;
}
person *node = (person *) malloc(sizeof(person));
newPerson(node, name);
person *node = newPerson(name);
if (*head == NULL || strcmp((*head)->name, name) > 0) {
node->next = *head;