Skip to content

⚙️ Refactor `struct Body`

Notifications You must be signed in to change notification settings

neomutt/test-body

Repository files navigation

Refactoring struct Body

Current Scheme

Key:

  • Green: Body->next
  • Red: Body->parts

next-parts

The Bodys are singly-linked.

Proposed Scheme

This scheme uses TAILQ to group the children. The Bodys are doubly-linked.

children

Sample Code

The sample code mimics an email with lots of nested attachments. The code recursively dumps the structures.

To compile: (with ASAN)

gcc -Wall -Wextra -Wpedantic -I. -fsanitize=address -o email *.c

To run:

./email

Output:

Email: refactoring
Body: apple
    Body: aardvark
    Body: antelope
Body: banana
    Body: baboon
    Body: buffalo
    Body: bat
Body: cherry
    Body: chameleon