[prev] 2 [next]

Assignment 1 Review (cont)

Decisions for stored representation:
  • split into local+domain  or  keep as one string
  • canonicalize before storing  or  when using operators
  • fixed-length structure  or  variable length structure
Typical solution:

struct Email { char local[128]; char domain[128]; }

Problems: wastes space, buffers too short (129 for '\0')

Better solution:

struct Email { int32 len; int32 dom0; char addr[1]; }

Assumes: copy whole string, convert to lower-case, replace '@' by '\0'