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:
parent
fb4e96919a
commit
64c2b7f0fd
21 changed files with 614 additions and 0 deletions
35
examples/c-linkedlist/PROTOKOLL.md
Normal file
35
examples/c-linkedlist/PROTOKOLL.md
Normal 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:**
|
||||
|
||||
---
|
||||
48
examples/c-linkedlist/README.md
Normal file
48
examples/c-linkedlist/README.md
Normal 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 1–5, 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
|
||||
```
|
||||
43
examples/c-linkedlist/linked_list.c
Normal file
43
examples/c-linkedlist/linked_list.c
Normal 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;
|
||||
}
|
||||
16
examples/c-linkedlist/linked_list.h
Normal file
16
examples/c-linkedlist/linked_list.h
Normal 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
|
||||
16
examples/c-linkedlist/main.c
Normal file
16
examples/c-linkedlist/main.c
Normal 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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue