feat: Demo-Examples (Python/Rust/Go/C) mit Protokoll-Templates und Restore-Skript

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Dieter Schlüter 2026-05-29 19:06:36 +02:00
commit 64c2b7f0fd
21 changed files with 614 additions and 0 deletions

View file

@ -0,0 +1,35 @@
# Demo-Protokoll: c-linkedlist
## Lauf 1
**Datum:**
**Befehl /quick_check:**
```
/quick_check "Gibt es Speicherlecks oder sonstige Probleme in diesem C-Projekt?"
```
**Startzeit:**
**Endzeit:**
**Dauer (min):**
**Ergebnis:** OK / PROBLEM (Kurzbeschreibung):
**Befehl /fix:**
```
/fix "Implementiere list_free() korrekt, sodass valgrind --leak-check=full sauber ist."
```
**Startzeit:**
**Endzeit:**
**Dauer (min):**
**Ergebnis:** erledigt / fehlgeschlagen
**Befehl /patch (optional):**
```
/patch "Ergänze list_search(head, value) in Header und Implementierung.
Gibt den ersten Node* mit dem gesuchten Wert zurück, oder NULL."
```
**Startzeit:**
**Endzeit:**
**Dauer (min):**
**Besonderheiten / Beobachtungen:**
---

View file

@ -0,0 +1,48 @@
# C Linked List
Vollständige einfach-verkettete Liste — bis auf `list_free()`, das als leerer Stub vorliegt.
Jeder Programmlauf leckt den gesamten Listen-Speicher.
## Aktueller Stand
```
linked_list.h Interface: node_new, list_prepend, list_append, list_print, list_free, list_length
linked_list.c Alles implementiert — außer list_free() (Stub, tut nichts)
main.c Baut Liste 15, gibt sie aus, ruft list_free() auf (ohne Wirkung)
```
## Demo 1: `/quick_check` als Diagnose
```
/quick_check "Gibt es Speicherlecks oder sonstige Probleme in diesem C-Projekt?"
```
Der Judge analysiert den Code und identifiziert das leere `list_free()` als Speicherleck-Quelle.
## Demo 2: `/fix` für gezieltes Nacharbeiten
```
/fix "Implementiere list_free() korrekt, sodass valgrind --leak-check=full sauber ist."
```
Coder implementiert die Funktion, committet. Kein vollständiger Judge-Loop —
ideal für kleine, klar abgegrenzte Fixes.
## Demo 3: `/patch` für Minimal-Erweiterungen
```
/patch "Ergänze list_search(head, value) in Header und Implementierung.
Gibt den ersten Node* mit dem gesuchten Wert zurück, oder NULL."
```
pi-coder wendet einen unified diff an (`apply_patch`-Tool), ohne den vollständigen Loop.
## Manueller Build
```bash
gcc -Wall -Wextra -o ll_demo linked_list.c main.c
./ll_demo
# Mit Leak-Check:
valgrind --leak-check=full ./ll_demo
```

View file

@ -0,0 +1,43 @@
#include <stdlib.h>
#include <stdio.h>
#include "linked_list.h"
Node *node_new(int value) {
Node *n = malloc(sizeof(Node));
n->value = value;
n->next = NULL;
return n;
}
Node *list_prepend(Node *head, int value) {
Node *n = node_new(value);
n->next = head;
return n;
}
Node *list_append(Node *head, int value) {
Node *n = node_new(value);
if (!head) return n;
Node *cur = head;
while (cur->next) cur = cur->next;
cur->next = n;
return head;
}
void list_print(const Node *head) {
for (const Node *cur = head; cur; cur = cur->next)
printf("%d ", cur->value);
printf("\n");
}
/* BUG: Speicher wird nicht freigegeben — valgrind meldet Leaks. */
void list_free(Node *head) {
(void)head; /* TODO: implementieren */
}
int list_length(const Node *head) {
int len = 0;
for (const Node *cur = head; cur; cur = cur->next)
len++;
return len;
}

View file

@ -0,0 +1,16 @@
#ifndef LINKED_LIST_H
#define LINKED_LIST_H
typedef struct Node {
int value;
struct Node *next;
} Node;
Node *node_new(int value);
Node *list_prepend(Node *head, int value);
Node *list_append(Node *head, int value);
void list_print(const Node *head);
void list_free(Node *head);
int list_length(const Node *head);
#endif

View file

@ -0,0 +1,16 @@
#include <stdio.h>
#include "linked_list.h"
int main(void) {
Node *list = NULL;
for (int i = 1; i <= 5; i++)
list = list_append(list, i);
printf("Liste: ");
list_print(list);
printf("Länge: %d\n", list_length(list));
list_free(list); /* leckt wegen unvollständigem TODO */
return 0;
}