case 0: /* Disabling */
case LLDP_MED_LOCFORMAT_COORD:
mloc->location->format = value;
- if (mloc->location->data) free(mloc->location->data);
+ free(mloc->location->data);
mloc->location->data = calloc(1, 16);
if (mloc->location->data == NULL) {
mloc->location->data_len = 0;
return atom;
case LLDP_MED_LOCFORMAT_CIVIC:
mloc->location->format = value;
- if (mloc->location->data) free(mloc->location->data);
+ free(mloc->location->data);
mloc->location->data = calloc(1, 4);
if (mloc->location->data == NULL) {
mloc->location->data_len = 0;
return atom;
case LLDP_MED_LOCFORMAT_ELIN:
mloc->location->format = value;
- if (mloc->location->data) free(mloc->location->data);
+ free(mloc->location->data);
mloc->location->data = NULL;
mloc->location->data_len = 0;
return atom;
case lldpctl_k_med_location_elin:
if (!value) goto bad;
if (mloc->location->format != LLDP_MED_LOCFORMAT_ELIN) goto bad;
- if (mloc->location->data) free(mloc->location->data);
+ free(mloc->location->data);
mloc->location->data = calloc(1, strlen(value));
if (mloc->location->data == NULL) {
mloc->location->data_len = 0;
int i;
current = (current + 1)%4;
- if (buffer[current]) free(buffer[current]); buffer[current] = NULL;
+ free(buffer[current]); buffer[current] = NULL;
for (i = 0; i < namelen; i++) {
/* Not very efficient... */
buffer[current] = NULL;
return NULL;
}
- if (buffer[current]) free(buffer[current]);
+ free(buffer[current]);
buffer[current] = newbuffer;
}
return buffer[current++];
{
static char *hex[] = { NULL, NULL };
static int which = 0;
- if (hex[which]) free(hex[which]); hex[which] = NULL;
+ free(hex[which]); hex[which] = NULL;
hex[which] = malloc(len * 3 + 1);
fail_unless(hex[which] != NULL, "Not enough memory?");
for (int i = 0; i < len; i++)