.destroy = _destroy,
},
.name = strdup(name),
- .updown = updown ? strdup(updown) : NULL,
+ .updown = strdupnull(updown),
.hostaccess = hostaccess,
.mode = mode,
.start_action = start_action,
this->use_mobike = mobike;
this->dpd = dpd;
this->virtual_ip = virtual_ip;
- this->pool = pool ? strdup(pool) : NULL;
+ this->pool = strdupnull(pool);
this->local_auth = linked_list_create();
this->remote_auth = linked_list_create();
this->refcount = 1;
DESTROY_IF(this->user);
this->user = id->clone(id);
free(this->pass);
- this->pass = password ? strdup(password) : NULL;
+ this->pass = strdupnull(password);
this->lock->unlock(this->lock);
}
DESTROY_IF(this->user);
this->user = id->clone(id);
free(this->pass);
- this->pass = password ? strdup(password) : NULL;
+ this->pass = strdupnull(password);
this->lock->unlock(this->lock);
}
{
this->lock->write_lock(this->lock);
free(this->keypass);
- this->keypass = password ? strdup(password) : NULL;
+ this->keypass = strdupnull(password);
this->lock->unlock(this->lock);
}
this->lock->write_lock(this->lock);
free(this->keypass);
free(this->keyid.ptr);
- this->keypass = pin ? strdup(pin) : NULL;
+ this->keypass = strdupnull(pin);
this->keyid = chunk_clone(keyid);
this->lock->unlock(this->lock);
}
private_request_t *this = (private_request_t*)thread_this->get(thread_this);
value = FCGX_GetParam(key, this->req.envp);
- return value ? strdup(value) : NULL;
+ return strdupnull(value);
}
/**
{
section_t *this;
INIT(this,
- .name = name ? strdup(name) : NULL,
+ .name = strdupnull(name),
.sections = linked_list_create(),
.kv = linked_list_create(),
);
*/
#define strncaseeq(x,y,len) (strncasecmp(x, y, len) == 0)
+/**
+ * NULL-safe strdup variant
+ */
+#define strdupnull(x) ({ char *_x = x; _x ? strdup(_x) : NULL; })
+
/**
* Macro compares two binary blobs for equality
*/