Don't check for NULL before free() Signed-off-by: Ran Benita <ran234@gmail.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797
diff --git a/src/alloc.c b/src/alloc.c
index 0966fc5..77aa638 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -102,8 +102,7 @@ XkbcFreeCompatMap(struct xkb_desc * xkb, unsigned which, Bool freeMap)
bzero(&compat->groups[0], XkbNumKbdGroups * sizeof(struct xkb_mods));
if (which & XkbSymInterpMask) {
- if (compat->sym_interpret && (compat->size_si > 0))
- free(compat->sym_interpret);
+ free(compat->sym_interpret);
compat->size_si = compat->num_si = 0;
compat->sym_interpret = NULL;
}
@@ -221,27 +220,25 @@ XkbcFreeNames(struct xkb_desc * xkb, unsigned which, Bool freeMap)
struct xkb_key_type * type = map->types;
for (i = 0; i < map->num_types; i++, type++) {
- if (type->level_names) {
- free(type->level_names);
- type->level_names = NULL;
- }
+ free(type->level_names);
+ type->level_names = NULL;
}
}
}
- if ((which & XkbKeyNamesMask) && names->keys) {
+ if (which & XkbKeyNamesMask) {
free(names->keys);
names->keys = NULL;
names->num_keys = 0;
}
- if ((which & XkbKeyAliasesMask) && names->key_aliases) {
+ if (which & XkbKeyAliasesMask) {
free(names->key_aliases);
names->key_aliases = NULL;
names->num_key_aliases = 0;
}
- if ((which & XkbRGNamesMask) && names->radio_groups) {
+ if (which & XkbRGNamesMask) {
free(names->radio_groups);
names->radio_groups = NULL;
names->num_rg = 0;
@@ -303,7 +300,7 @@ XkbcAllocIndicatorMaps(struct xkb_desc * xkb)
static void
XkbcFreeIndicatorMaps(struct xkb_desc * xkb)
{
- if (xkb && xkb->indicators) {
+ if (xkb) {
free(xkb->indicators);
xkb->indicators = NULL;
}
diff --git a/src/galloc.c b/src/galloc.c
index a6d7d7a..cb0b0f8 100644
--- a/src/galloc.c
+++ b/src/galloc.c
@@ -38,10 +38,8 @@ _XkbFreeGeomLeafElems(Bool freeAll, int first, int count,
{
if (freeAll || !(*elems)) {
*num_inout = *sz_inout = 0;
- if (*elems) {
- free(*elems);
- *elems = NULL;
- }
+ free(*elems);
+ *elems = NULL;
return;
}
@@ -97,10 +95,8 @@ _XkbFreeGeomNonLeafElems(Bool freeAll, int first, int count,
if (freeAll) {
*num_inout = *sz_inout = 0;
- if (*elems) {
- free(*elems);
- *elems = NULL;
- }
+ free(*elems);
+ *elems = NULL;
}
else if (first + count >= (*num_inout))
*num_inout = first;
@@ -117,14 +113,10 @@ _XkbClearProperty(char *prop_in)
{
struct xkb_property * prop = (struct xkb_property *)prop_in;
- if (prop->name) {
- free(prop->name);
- prop->name = NULL;
- }
- if (prop->value) {
- free(prop->value);
- prop->value = NULL;
- }
+ free(prop->name);
+ prop->name = NULL;
+ free(prop->value);
+ prop->value = NULL;
}
static void
@@ -151,8 +143,7 @@ _XkbClearColor(char *color_in)
{
struct xkb_color * color = (struct xkb_color *)color_in;
- if (color->spec)
- free(color->spec);
+ free(color->spec);
}
static void
@@ -243,21 +234,15 @@ _XkbClearDoodad(char *doodad_in)
switch (doodad->any.type) {
case XkbTextDoodad:
- if (doodad->text.text) {
- free(doodad->text.text);
- doodad->text.text = NULL;
- }
- if (doodad->text.font) {
- free(doodad->text.font);
- doodad->text.font = NULL;
- }
+ free(doodad->text.text);
+ doodad->text.text = NULL;
+ free(doodad->text.font);
+ doodad->text.font = NULL;
break;
case XkbLogoDoodad:
- if (doodad->logo.logo_name) {
- free(doodad->logo.logo_name);
- doodad->logo.logo_name = NULL;
- }
+ free(doodad->logo.logo_name);
+ doodad->logo.logo_name = NULL;
break;
}
}
@@ -268,12 +253,10 @@ XkbcFreeGeomDoodads(union xkb_doodad * doodads, int nDoodads, Bool freeAll)
int i;
union xkb_doodad * doodad;
- if (doodads) {
- for (i = 0, doodad = doodads; i < nDoodads; i++, doodad++)
- _XkbClearDoodad((char *)doodad);
- if (freeAll)
- free(doodads);
- }
+ for (i = 0, doodad = doodads; i < nDoodads && doodad; i++, doodad++)
+ _XkbClearDoodad((char *)doodad);
+ if (freeAll)
+ free(doodads);
}
static void
@@ -283,10 +266,8 @@ _XkbClearSection(char *section_in)
if (section->rows)
XkbcFreeGeomRows(section, 0, section->num_rows, True);
- if (section->doodads) {
- XkbcFreeGeomDoodads(section->doodads, section->num_doodads, True);
- section->doodads = NULL;
- }
+ XkbcFreeGeomDoodads(section->doodads, section->num_doodads, True);
+ section->doodads = NULL;
}
static void
@@ -329,10 +310,8 @@ XkbcFreeGeometry(struct xkb_geometry * geom, unsigned which, Bool freeMap)
XkbcFreeGeomKeyAliases(geom, 0, geom->num_key_aliases, True);
if (freeMap) {
- if (geom->label_font) {
- free(geom->label_font);
- geom->label_font = NULL;
- }
+ free(geom->label_font);
+ geom->label_font = NULL;
free(geom);
}
}
@@ -483,8 +462,7 @@ register struct xkb_property * prop;
return NULL;
for (i=0,prop=geom->properties;i<geom->num_properties;i++,prop++) {
if ((prop->name)&&(strcmp(name,prop->name)==0)) {
- if (prop->value)
- free(prop->value);
+ free(prop->value);
prop->value= (char *)malloc(strlen(value)+1);
if (prop->value)
strcpy(prop->value,value);
@@ -644,11 +622,9 @@ struct xkb_section * section;
if ((sz_rows>0)&&(_XkbAllocRows(section,sz_rows)!=Success))
return NULL;
if ((sz_doodads>0)&&(_XkbAllocDoodads(section,sz_doodads)!=Success)) {
- if (section->rows) {
- free(section->rows);
- section->rows= NULL;
- section->sz_rows= section->num_rows= 0;
- }
+ free(section->rows);
+ section->rows= NULL;
+ section->sz_rows= section->num_rows= 0;
return NULL;
}
section->name= name;
diff --git a/src/malloc.c b/src/malloc.c
index b6144f1..965821c 100644
--- a/src/malloc.c
+++ b/src/malloc.c
@@ -217,18 +217,12 @@ XkbcCopyKeyType(struct xkb_key_type * from, struct xkb_key_type * into)
if (!from || !into)
return BadMatch;
- if (into->map) {
- free(into->map);
- into->map = NULL;
- }
- if (into->preserve) {
- free(into->preserve);
- into->preserve= NULL;
- }
- if (into->level_names) {
- free(into->level_names);
- into->level_names = NULL;
- }
+ free(into->map);
+ into->map = NULL;
+ free(into->preserve);
+ into->preserve= NULL;
+ free(into->level_names);
+ into->level_names = NULL;
*into = *from;
@@ -397,46 +391,32 @@ XkbcFreeClientMap(struct xkb_desc * xkb, unsigned what, Bool freeMap)
map = xkb->map;
if (what & XkbKeyTypesMask) {
- if (map->types) {
- if (map->num_types > 0) {
- int i;
- struct xkb_key_type * type;
-
- for (i = 0, type = map->types; i < map->num_types; i++, type++) {
- if (type->map) {
- free(type->map);
- type->map = NULL;
- }
- if (type->preserve) {
- free(type->preserve);
- type->preserve = NULL;
- }
- type->map_count = 0;
- if (type->level_names) {
- free(type->level_names);
- type->level_names = NULL;
- }
- }
- }
- free(map->types);
- map->num_types = map->size_types = 0;
- map->types = NULL;
+ int i;
+ struct xkb_key_type * type;
+
+ for (i = 0, type = map->types; i < map->num_types && type; i++, type++) {
+ free(type->map);
+ type->map = NULL;
+ free(type->preserve);
+ type->preserve = NULL;
+ type->map_count = 0;
+ free(type->level_names);
+ type->level_names = NULL;
}
+ free(map->types);
+ map->num_types = map->size_types = 0;
+ map->types = NULL;
}
if (what & XkbKeySymsMask) {
- if (map->key_sym_map) {
- free(map->key_sym_map);
- map->key_sym_map = NULL;
- }
- if (map->syms) {
- free(map->syms);
- map->size_syms = map->num_syms = 0;
- map->syms = NULL;
- }
+ free(map->key_sym_map);
+ map->key_sym_map = NULL;
+ free(map->syms);
+ map->size_syms = map->num_syms = 0;
+ map->syms = NULL;
}
- if ((what & XkbModifierMapMask) && map->modmap) {
+ if (what & XkbModifierMapMask) {
free(map->modmap);
map->modmap = NULL;
}
@@ -459,29 +439,25 @@ XkbcFreeServerMap(struct xkb_desc * xkb, unsigned what, Bool freeMap)
what = XkbAllServerInfoMask;
map = xkb->server;
- if ((what & XkbExplicitComponentsMask) && map->explicit) {
+ if (what & XkbExplicitComponentsMask) {
free(map->explicit);
map->explicit = NULL;
}
if (what & XkbKeyActionsMask) {
- if (map->key_acts) {
- free(map->key_acts);
- map->key_acts = NULL;
- }
- if (map->acts) {
- free(map->acts);
- map->num_acts = map->size_acts = 0;
- map->acts = NULL;
- }
+ free(map->key_acts);
+ map->key_acts = NULL;
+ free(map->acts);
+ map->num_acts = map->size_acts = 0;
+ map->acts = NULL;
}
- if ((what & XkbKeyBehaviorsMask) && map->behaviors) {
+ if (what & XkbKeyBehaviorsMask) {
free(map->behaviors);
map->behaviors = NULL;
}
- if ((what & XkbVirtualModMapMask) && map->vmodmap) {
+ if (what & XkbVirtualModMapMask) {
free(map->vmodmap);
map->vmodmap = NULL;
}
diff --git a/src/maprules.c b/src/maprules.c
index 49761be..ad542db 100644
--- a/src/maprules.c
+++ b/src/maprules.c
@@ -578,13 +578,10 @@ MakeMultiDefs(XkbRF_MultiDefsPtr mdefs, XkbRF_VarDefsPtr defs)
static void
FreeMultiDefs(XkbRF_MultiDefsPtr defs)
{
- if (defs->options)
free(defs->options);
- /* Avoid -Wcast-qual warnings. */
- if (defs->layout[1])
+ /* Avoid -Wcast-qual warnings. */
free((void *)(uintptr_t)defs->layout[1]);
- if (defs->variant[1])
- free((void *)(uintptr_t)defs->variant[1]);
+ free((void *)(uintptr_t)defs->variant[1]);
}
static void
@@ -976,14 +973,11 @@ XkbRF_ClearVarDescriptions(XkbRF_DescribeVarsPtr var)
register int i;
for (i=0;i<var->num_desc;i++) {
- if (var->desc[i].name)
- free(var->desc[i].name);
- if (var->desc[i].desc)
- free(var->desc[i].desc);
+ free(var->desc[i].name);
+ free(var->desc[i].desc);
var->desc[i].name= var->desc[i].desc= NULL;
}
- if (var->desc)
- free(var->desc);
+ free(var->desc);
var->desc= NULL;
return;
}
@@ -1009,34 +1003,31 @@ XkbRF_GroupPtr group;
rules->num_extra= rules->sz_extra= 0;
rules->extra= NULL;
}
- if (rules->rules) {
- for (i=0,rule=rules->rules;i<rules->num_rules;i++,rule++) {
- if (rule->model) free(rule->model);
- if (rule->layout) free(rule->layout);
- if (rule->variant) free(rule->variant);
- if (rule->option) free(rule->option);
- if (rule->keycodes) free(rule->keycodes);
- if (rule->symbols) free(rule->symbols);
- if (rule->types) free(rule->types);
- if (rule->compat) free(rule->compat);
- if (rule->geometry) free(rule->geometry);
- if (rule->keymap) free(rule->keymap);
- bzero((char *)rule,sizeof(XkbRF_RuleRec));
- }
- free(rules->rules);
- rules->num_rules= rules->sz_rules= 0;
- rules->rules= NULL;
+ for (i=0, rule = rules->rules; i < rules->num_rules && rules; i++, rule++) {
+ free(rule->model);
+ free(rule->layout);
+ free(rule->variant);
+ free(rule->option);
+ free(rule->keycodes);
+ free(rule->symbols);
+ free(rule->types);
+ free(rule->compat);
+ free(rule->geometry);
+ free(rule->keymap);
+ bzero((char *)rule,sizeof(XkbRF_RuleRec));
}
+ free(rules->rules);
+ rules->num_rules= rules->sz_rules= 0;
+ rules->rules= NULL;
- if (rules->groups) {
- for (i=0, group=rules->groups;i<rules->num_groups;i++,group++) {
- if (group->name) free(group->name);
- if (group->words) free(group->words);
- }
- free(rules->groups);
- rules->num_groups= 0;
- rules->groups= NULL;
+ for (i=0, group = rules->groups; i < rules->num_groups && group; i++, group++) {
+ free(group->name);
+ free(group->words);
}
+ free(rules->groups);
+ rules->num_groups= 0;
+ rules->groups= NULL;
+
if (freeRules)
free(rules);
return;
diff --git a/src/xkbcomp/compat.c b/src/xkbcomp/compat.c
index 9b268e6..712c69d 100644
--- a/src/xkbcomp/compat.c
+++ b/src/xkbcomp/compat.c
@@ -137,8 +137,7 @@ ClearCompatInfo(CompatInfo * info, struct xkb_desc * xkb)
{
register int i;
- if (info->name != NULL)
- free(info->name);
+ free(info->name);
info->name = NULL;
info->dflt.defs.defined = 0;
info->dflt.defs.merge = MergeAugment;
@@ -426,8 +425,7 @@ HandleIncludeCompatMap(IncludeStmt * stmt,
(*hndlr) (rtrn, xkb, MergeOverride, &included);
if (stmt->stmt != NULL)
{
- if (included.name != NULL)
- free(included.name);
+ free(included.name);
included.name = stmt->stmt;
stmt->stmt = NULL;
}
@@ -857,7 +855,6 @@ CompileCompatMap(XkbFile *file, struct xkb_desc * xkb, unsigned merge,
ClearCompatInfo(&info, xkb);
return True;
}
- if (info.interps != NULL)
- free(info.interps);
+ free(info.interps);
return False;
}
diff --git a/src/xkbcomp/geometry.c b/src/xkbcomp/geometry.c
index bb3a891..37e8784 100644
--- a/src/xkbcomp/geometry.c
+++ b/src/xkbcomp/geometry.c
@@ -292,10 +292,8 @@ FreeProperties(PropertyInfo * pi, GeometryInfo * info)
}
for (tmp = pi; tmp != NULL; tmp = next)
{
- if (tmp->name)
- free(tmp->name);
- if (tmp->value)
- free(tmp->value);
+ free(tmp->name);
+ free(tmp->value);
tmp->name = tmp->value = NULL;
next = (PropertyInfo *) tmp->defs.next;
free(tmp);
@@ -674,8 +672,7 @@ InitGeometryInfo(GeometryInfo * info, unsigned fileID, unsigned merge)
static void
ClearGeometryInfo(GeometryInfo * info)
{
- if (info->name)
- free(info->name);
+ free(info->name);
info->name = NULL;
if (info->props)
FreeProperties(info->props, info);
@@ -748,8 +745,7 @@ AddProperty(GeometryInfo * info, PropertyInfo * new)
ACTION("Ignoring \"%s\", using \"%s\"\n", old->value,
new->value);
}
- if (old->value)
- free(old->value);
+ free(old->value);
old->value = _XkbDupString(new->value);
return True;
}
@@ -1344,8 +1340,7 @@ HandleIncludeGeometry(IncludeStmt * stmt, struct xkb_desc * xkb, GeometryInfo *
(*hndlr) (rtrn, xkb, MergeOverride, &included);
if (stmt->stmt != NULL)
{
- if (included.name != NULL)
- free(included.name);
+ free(included.name);
included.name = stmt->stmt;
stmt->stmt = NULL;
}
diff --git a/src/xkbcomp/keycodes.c b/src/xkbcomp/keycodes.c
index e24764e..98fa699 100644
--- a/src/xkbcomp/keycodes.c
+++ b/src/xkbcomp/keycodes.c
@@ -320,8 +320,7 @@ AddIndicatorName(KeyNamesInfo * info, IndicatorNameInfo * new)
static void
ClearKeyNamesInfo(KeyNamesInfo * info)
{
- if (info->name != NULL)
- free(info->name);
+ free(info->name);
info->name = NULL;
info->computedMax = info->explicitMax = info->explicitMin = 0;
info->computedMin = XKB_KEYCODE_MAX;
@@ -578,8 +577,7 @@ HandleIncludeKeycodes(IncludeStmt * stmt, struct xkb_desc * xkb, KeyNamesInfo *
HandleKeycodesFile(rtrn, xkb, MergeOverride, &included);
if (stmt->stmt != NULL)
{
- if (included.name != NULL)
- free(included.name);
+ free(included.name);
included.name = stmt->stmt;
stmt->stmt = NULL;
}
diff --git a/src/xkbcomp/keytypes.c b/src/xkbcomp/keytypes.c
index 12ea942..ec3ee70 100644
--- a/src/xkbcomp/keytypes.c
+++ b/src/xkbcomp/keytypes.c
@@ -179,16 +179,10 @@ InitKeyTypesInfo(KeyTypesInfo * info, struct xkb_desc * xkb, KeyTypesInfo * from
static void
FreeKeyTypeInfo(KeyTypeInfo * type)
{
- if (type->entries != NULL)
- {
- free(type->entries);
- type->entries = NULL;
- }
- if (type->lvlNames != NULL)
- {
- free(type->lvlNames);
- type->lvlNames = NULL;
- }
+ free(type->entries);
+ type->entries = NULL;
+ free(type->lvlNames);
+ type->lvlNames = NULL;
if (type->preserve != NULL)
{
ClearCommonInfo(&type->preserve->defs);
@@ -200,8 +194,7 @@ FreeKeyTypeInfo(KeyTypeInfo * type)
static void
FreeKeyTypesInfo(KeyTypesInfo * info)
{
- if (info->name)
- free(info->name);
+ free(info->name);
info->name = NULL;
if (info->types)
{
@@ -397,8 +390,7 @@ HandleIncludeKeyTypes(IncludeStmt * stmt,
(*hndlr) (rtrn, xkb, newMerge, &included);
if (stmt->stmt != NULL)
{
- if (included.name != NULL)
- free(included.name);
+ free(included.name);
included.name = stmt->stmt;
stmt->stmt = NULL;
}
diff --git a/src/xkbcomp/parseutils.c b/src/xkbcomp/parseutils.c
index 65de324..a645744 100644
--- a/src/xkbcomp/parseutils.c
+++ b/src/xkbcomp/parseutils.c
@@ -540,10 +540,8 @@ OverlayKeyCreate(char *under, char *over)
key->common.stmtType = StmtOverlayKeyDef;
strncpy(key->over, over, XkbKeyNameLength);
strncpy(key->under, under, XkbKeyNameLength);
- if (over)
- free(over);
- if (under)
- free(under);
+ free(over);
+ free(under);
}
return key;
}
@@ -694,7 +692,7 @@ IncludeCreate(char *str, unsigned merge)
}
if (first)
first->stmt = stmt;
- else if (stmt)
+ else
free(stmt);
return first;
BAIL:
@@ -703,20 +701,15 @@ IncludeCreate(char *str, unsigned merge)
while (first)
{
incl = first->next;
- if (first->file)
- free(first->file);
- if (first->map)
- free(first->map);
- if (first->modifier)
- free(first->modifier);
- if (first->path)
- free(first->path);
+ free(first->file);
+ free(first->map);
+ free(first->modifier);
+ free(first->path);
first->file = first->map = first->path = NULL;
free(first);
first = incl;
}
- if (stmt)
- free(stmt);
+ free(stmt);
return NULL;
}
diff --git a/src/xkbcomp/symbols.c b/src/xkbcomp/symbols.c
index 2a89598..f0d7bc7 100644
--- a/src/xkbcomp/symbols.c
+++ b/src/xkbcomp/symbols.c
@@ -130,11 +130,9 @@ FreeKeyInfo(KeyInfo * info)
{
info->numLevels[i] = 0;
info->types[i] = None;
- if (info->syms[i] != NULL)
- free(info->syms[i]);
+ free(info->syms[i]);
info->syms[i] = NULL;
- if (info->acts[i] != NULL)
- free(info->acts[i]);
+ free(info->acts[i]);
info->acts[i] = NULL;
}
info->dfltType = None;
@@ -270,28 +268,17 @@ FreeSymbolsInfo(SymbolsInfo * info)
{
register int i;
- if (info->name)
- free(info->name);
- info->name = NULL;
+ free(info->name);
if (info->keys)
{
for (i = 0; i < info->nKeys; i++)
- {
FreeKeyInfo(&info->keys[i]);
- }
free(info->keys);
- info->keys = NULL;
}
if (info->modMap)
- {
ClearCommonInfo(&info->modMap->defs);
- info->modMap = NULL;
- }
if (info->aliases)
- {
ClearAliases(&info->aliases);
- info->aliases = NULL;
- }
bzero((char *) info, sizeof(SymbolsInfo));
return;
}
@@ -457,13 +444,13 @@ MergeKeyGroups(SymbolsInfo * info,
}
}
}
- if ((into->syms[group] != NULL) && (resultSyms != into->syms[group]))
+ if (resultSyms != into->syms[group])
free(into->syms[group]);
- if ((from->syms[group] != NULL) && (resultSyms != from->syms[group]))
+ if (resultSyms != from->syms[group])
free(from->syms[group]);
- if ((into->acts[group] != NULL) && (resultActs != into->acts[group]))
+ if (resultActs != into->acts[group])
free(into->acts[group]);
- if ((from->acts[group] != NULL) && (resultActs != from->acts[group]))
+ if (resultActs != from->acts[group])
free(from->acts[group]);
into->numLevels[group] = resultWidth;
into->syms[group] = resultSyms;
@@ -490,10 +477,8 @@ MergeKeys(SymbolsInfo * info, KeyInfo * into, KeyInfo * from)
{
if (into->numLevels[i] != 0)
{
- if (into->syms[i])
- free(into->syms[i]);
- if (into->acts[i])
- free(into->acts[i]);
+ free(into->syms[i]);
+ free(into->acts[i]);
}
}
*into = *from;
@@ -801,8 +786,7 @@ HandleIncludeSymbols(IncludeStmt * stmt,
(*hndlr) (rtrn, xkb, MergeOverride, &included);
if (stmt->stmt != NULL)
{
- if (included.name != NULL)
- free(included.name);
+ free(included.name);
included.name = stmt->stmt;
stmt->stmt = NULL;
}
@@ -1507,11 +1491,9 @@ SetExplicitGroup(SymbolsInfo * info, KeyInfo * key)
for (i = 1; i < XkbNumKbdGroups; i++)
{
key->numLevels[i] = 0;
- if (key->syms[i] != NULL)
- free(key->syms[i]);
+ free(key->syms[i]);
key->syms[i] = (uint32_t *) NULL;
- if (key->acts[i] != NULL)
- free(key->acts[i]);
+ free(key->acts[i]);
key->acts[i] = (union xkb_action *) NULL;
key->types[i] = (uint32_t) 0;
}
@@ -1873,11 +1855,9 @@ PrepareKeyDef(KeyInfo * key)
for (i = lastGroup; i > 0; i--)
{
key->numLevels[i] = 0;
- if (key->syms[i] != NULL)
- free(key->syms[i]);
+ free(key->syms[i]);
key->syms[i] = (uint32_t *) NULL;
- if (key->acts[i] != NULL)
- free(key->acts[i]);
+ free(key->acts[i]);
key->acts[i] = (union xkb_action *) NULL;
key->types[i] = (uint32_t) 0;
}
diff --git a/src/xkbcomp/xkbparse.y b/src/xkbcomp/xkbparse.y
index cf3db91..5a6e45f 100644
--- a/src/xkbcomp/xkbparse.y
+++ b/src/xkbcomp/xkbparse.y
@@ -332,8 +332,7 @@ KeyNameDecl : KeyName EQUALS KeyCode SEMI
KeycodeDef *def;
def= KeycodeCreate($1,$3);
- if ($1)
- free($1);
+ free($1);
$$= def;
}
;
@@ -342,8 +341,8 @@ KeyAliasDecl : ALIAS KeyName EQUALS KeyName SEMI
{
KeyAliasDef *def;
def= KeyAliasCreate($2,$4);
- if ($2) free($2);
- if ($4) free($4);
+ free($2);
+ free($4);
$$= def;
}
;
diff --git a/src/xkbcomp/xkbscan.l b/src/xkbcomp/xkbscan.l
index adf03db..4b02b65 100644
--- a/src/xkbcomp/xkbscan.l
+++ b/src/xkbcomp/xkbscan.l
@@ -199,8 +199,7 @@ yyerror(const char *msg)
void setScanState(const char *file, int lineno)
{
yylineno = 1;
- if (scanFile)
- free(scanFile);
+ free(scanFile);
scanFile = strdup(file);
}