4 ms·
The title is misleading. Their "error codes" are not simple C error codes but are rather structs which they are dynamically allocating upon error occurence. T
by vancan1ty 10y ago
The title is misleading. Their "error codes" are not simple C error codes but are rather structs which they are dynamically allocating upon error occurence. Their "create_error" function below is very inefficient compared to using traditional int error codes with a lookup table for the messages.
struct Error* create_error(const char *msg) {
struct Error *e = malloc(sizeof(struct Error));
e->msg = strdup(msg);
return e;
}