Christoph Mallon: Remove pointless if (x) before SDL_free(x)
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 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382
diff --git a/src/SDL_hints.c b/src/SDL_hints.c
index 63be87a..a1eae9f 100644
--- a/src/SDL_hints.c
+++ b/src/SDL_hints.c
@@ -72,9 +72,7 @@ SDL_SetHintWithPriority(const char *name, const char *value,
entry->callback(entry->userdata, name, hint->value, value);
entry = next;
}
- if (hint->value) {
- SDL_free(hint->value);
- }
+ SDL_free(hint->value);
hint->value = value ? SDL_strdup(value) : NULL;
}
hint->priority = priority;
@@ -206,9 +204,7 @@ void SDL_ClearHints(void)
SDL_hints = hint->next;
SDL_free(hint->name);
- if (hint->value) {
- SDL_free(hint->value);
- }
+ SDL_free(hint->value);
for (entry = hint->callbacks; entry; ) {
SDL_HintWatch *freeable = entry;
entry = entry->next;
diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c
index 69e6bf1..5631bb2 100644
--- a/src/audio/SDL_audio.c
+++ b/src/audio/SDL_audio.c
@@ -300,9 +300,7 @@ SDL_StreamInit(SDL_AudioStreamer * stream, int max_len, Uint8 silence)
static void
SDL_StreamDeinit(SDL_AudioStreamer * stream)
{
- if (stream->buffer != NULL) {
- SDL_free(stream->buffer);
- }
+ SDL_free(stream->buffer);
}
#if defined(ANDROID)
@@ -632,9 +630,7 @@ free_device_list(char ***devices, int *devCount)
}
}
- if (*devices != NULL) {
- SDL_free(*devices);
- }
+ SDL_free(*devices);
*devices = NULL;
*devCount = 0;
@@ -761,9 +757,7 @@ close_audio_device(SDL_AudioDevice * device)
if (device->mixer_lock != NULL) {
SDL_DestroyMutex(device->mixer_lock);
}
- if (device->fake_stream != NULL) {
- SDL_FreeAudioMem(device->fake_stream);
- }
+ SDL_FreeAudioMem(device->fake_stream);
if (device->convert.needed) {
SDL_FreeAudioMem(device->convert.buf);
}
diff --git a/src/audio/SDL_wave.c b/src/audio/SDL_wave.c
index d9ff165..fac24cb 100644
--- a/src/audio/SDL_wave.c
+++ b/src/audio/SDL_wave.c
@@ -449,10 +449,8 @@ SDL_LoadWAV_RW(SDL_RWops * src, int freesrc,
/* Read the audio data format chunk */
chunk.data = NULL;
do {
- if (chunk.data != NULL) {
- SDL_free(chunk.data);
- chunk.data = NULL;
- }
+ SDL_free(chunk.data);
+ chunk.data = NULL;
lenread = ReadChunk(src, &chunk);
if (lenread < 0) {
was_error = 1;
@@ -549,10 +547,8 @@ SDL_LoadWAV_RW(SDL_RWops * src, int freesrc,
/* Read the audio data chunk */
*audio_buf = NULL;
do {
- if (*audio_buf != NULL) {
- SDL_free(*audio_buf);
- *audio_buf = NULL;
- }
+ SDL_free(*audio_buf);
+ *audio_buf = NULL;
lenread = ReadChunk(src, &chunk);
if (lenread < 0) {
was_error = 1;
@@ -583,9 +579,7 @@ SDL_LoadWAV_RW(SDL_RWops * src, int freesrc,
*audio_len &= ~(samplesize - 1);
done:
- if (format != NULL) {
- SDL_free(format);
- }
+ SDL_free(format);
if (src) {
if (freesrc) {
SDL_RWclose(src);
@@ -606,9 +600,7 @@ SDL_LoadWAV_RW(SDL_RWops * src, int freesrc,
void
SDL_FreeWAV(Uint8 * audio_buf)
{
- if (audio_buf != NULL) {
- SDL_free(audio_buf);
- }
+ SDL_free(audio_buf);
}
static int
diff --git a/src/audio/alsa/SDL_alsa_audio.c b/src/audio/alsa/SDL_alsa_audio.c
index 7c57924..73bdcf2 100644
--- a/src/audio/alsa/SDL_alsa_audio.c
+++ b/src/audio/alsa/SDL_alsa_audio.c
@@ -340,10 +340,8 @@ static void
ALSA_CloseDevice(_THIS)
{
if (this->hidden != NULL) {
- if (this->hidden->mixbuf != NULL) {
- SDL_FreeAudioMem(this->hidden->mixbuf);
- this->hidden->mixbuf = NULL;
- }
+ SDL_FreeAudioMem(this->hidden->mixbuf);
+ this->hidden->mixbuf = NULL;
if (this->hidden->pcm_handle) {
ALSA_snd_pcm_drain(this->hidden->pcm_handle);
ALSA_snd_pcm_close(this->hidden->pcm_handle);
diff --git a/src/audio/arts/SDL_artsaudio.c b/src/audio/arts/SDL_artsaudio.c
index ac0bb9d..bd80643 100644
--- a/src/audio/arts/SDL_artsaudio.c
+++ b/src/audio/arts/SDL_artsaudio.c
@@ -204,10 +204,8 @@ static void
ARTS_CloseDevice(_THIS)
{
if (this->hidden != NULL) {
- if (this->hidden->mixbuf != NULL) {
- SDL_FreeAudioMem(this->hidden->mixbuf);
- this->hidden->mixbuf = NULL;
- }
+ SDL_FreeAudioMem(this->hidden->mixbuf);
+ this->hidden->mixbuf = NULL;
if (this->hidden->stream) {
SDL_NAME(arts_close_stream) (this->hidden->stream);
this->hidden->stream = 0;
diff --git a/src/audio/bsd/SDL_bsdaudio.c b/src/audio/bsd/SDL_bsdaudio.c
index b63c838..ad51dc3 100644
--- a/src/audio/bsd/SDL_bsdaudio.c
+++ b/src/audio/bsd/SDL_bsdaudio.c
@@ -214,10 +214,8 @@ static void
BSDAUDIO_CloseDevice(_THIS)
{
if (this->hidden != NULL) {
- if (this->hidden->mixbuf != NULL) {
- SDL_FreeAudioMem(this->hidden->mixbuf);
- this->hidden->mixbuf = NULL;
- }
+ SDL_FreeAudioMem(this->hidden->mixbuf);
+ this->hidden->mixbuf = NULL;
if (this->hidden->audio_fd >= 0) {
close(this->hidden->audio_fd);
this->hidden->audio_fd = -1;
diff --git a/src/audio/disk/SDL_diskaudio.c b/src/audio/disk/SDL_diskaudio.c
index 2286ba0..0dc650e 100644
--- a/src/audio/disk/SDL_diskaudio.c
+++ b/src/audio/disk/SDL_diskaudio.c
@@ -88,10 +88,8 @@ static void
DISKAUD_CloseDevice(_THIS)
{
if (this->hidden != NULL) {
- if (this->hidden->mixbuf != NULL) {
- SDL_FreeAudioMem(this->hidden->mixbuf);
- this->hidden->mixbuf = NULL;
- }
+ SDL_FreeAudioMem(this->hidden->mixbuf);
+ this->hidden->mixbuf = NULL;
if (this->hidden->output != NULL) {
SDL_RWclose(this->hidden->output);
this->hidden->output = NULL;
diff --git a/src/audio/dsp/SDL_dspaudio.c b/src/audio/dsp/SDL_dspaudio.c
index c62a22f..e319017 100644
--- a/src/audio/dsp/SDL_dspaudio.c
+++ b/src/audio/dsp/SDL_dspaudio.c
@@ -61,10 +61,8 @@ static void
DSP_CloseDevice(_THIS)
{
if (this->hidden != NULL) {
- if (this->hidden->mixbuf != NULL) {
- SDL_FreeAudioMem(this->hidden->mixbuf);
- this->hidden->mixbuf = NULL;
- }
+ SDL_FreeAudioMem(this->hidden->mixbuf);
+ this->hidden->mixbuf = NULL;
if (this->hidden->audio_fd >= 0) {
close(this->hidden->audio_fd);
this->hidden->audio_fd = -1;
diff --git a/src/audio/esd/SDL_esdaudio.c b/src/audio/esd/SDL_esdaudio.c
index 92716f3..c630565 100644
--- a/src/audio/esd/SDL_esdaudio.c
+++ b/src/audio/esd/SDL_esdaudio.c
@@ -176,10 +176,8 @@ static void
ESD_CloseDevice(_THIS)
{
if (this->hidden != NULL) {
- if (this->hidden->mixbuf != NULL) {
- SDL_FreeAudioMem(this->hidden->mixbuf);
- this->hidden->mixbuf = NULL;
- }
+ SDL_FreeAudioMem(this->hidden->mixbuf);
+ this->hidden->mixbuf = NULL;
if (this->hidden->audio_fd >= 0) {
SDL_NAME(esd_close) (this->hidden->audio_fd);
this->hidden->audio_fd = -1;
diff --git a/src/audio/fusionsound/SDL_fsaudio.c b/src/audio/fusionsound/SDL_fsaudio.c
index 2e468d5..49ad2c1 100644
--- a/src/audio/fusionsound/SDL_fsaudio.c
+++ b/src/audio/fusionsound/SDL_fsaudio.c
@@ -169,10 +169,8 @@ static void
SDL_FS_CloseDevice(_THIS)
{
if (this->hidden != NULL) {
- if (this->hidden->mixbuf != NULL) {
- SDL_FreeAudioMem(this->hidden->mixbuf);
- this->hidden->mixbuf = NULL;
- }
+ SDL_FreeAudioMem(this->hidden->mixbuf);
+ this->hidden->mixbuf = NULL;
if (this->hidden->stream) {
this->hidden->stream->Release(this->hidden->stream);
this->hidden->stream = NULL;
diff --git a/src/audio/nas/SDL_nasaudio.c b/src/audio/nas/SDL_nasaudio.c
index 4e3dc0a..c2bf677 100644
--- a/src/audio/nas/SDL_nasaudio.c
+++ b/src/audio/nas/SDL_nasaudio.c
@@ -191,10 +191,8 @@ static void
NAS_CloseDevice(_THIS)
{
if (this->hidden != NULL) {
- if (this->hidden->mixbuf != NULL) {
- SDL_FreeAudioMem(this->hidden->mixbuf);
- this->hidden->mixbuf = NULL;
- }
+ SDL_FreeAudioMem(this->hidden->mixbuf);
+ this->hidden->mixbuf = NULL;
if (this->hidden->aud) {
NAS_AuCloseServer(this->hidden->aud);
this->hidden->aud = 0;
diff --git a/src/audio/paudio/SDL_paudio.c b/src/audio/paudio/SDL_paudio.c
index 5a18b45..6584ddd 100644
--- a/src/audio/paudio/SDL_paudio.c
+++ b/src/audio/paudio/SDL_paudio.c
@@ -231,10 +231,8 @@ static void
PAUDIO_CloseDevice(_THIS)
{
if (this->hidden != NULL) {
- if (this->hidden->mixbuf != NULL) {
- SDL_FreeAudioMem(this->hidden->mixbuf);
- this->hidden->mixbuf = NULL;
- }
+ SDL_FreeAudioMem(this->hidden->mixbuf);
+ this->hidden->mixbuf = NULL;
if (this->hidden->audio_fd >= 0) {
close(this->hidden->audio_fd);
this->hidden->audio_fd = -1;
diff --git a/src/audio/pulseaudio/SDL_pulseaudio.c b/src/audio/pulseaudio/SDL_pulseaudio.c
index 46269d1..7bf4acc 100644
--- a/src/audio/pulseaudio/SDL_pulseaudio.c
+++ b/src/audio/pulseaudio/SDL_pulseaudio.c
@@ -300,10 +300,8 @@ static void
PULSEAUDIO_CloseDevice(_THIS)
{
if (this->hidden != NULL) {
- if (this->hidden->mixbuf != NULL) {
- SDL_FreeAudioMem(this->hidden->mixbuf);
- this->hidden->mixbuf = NULL;
- }
+ SDL_FreeAudioMem(this->hidden->mixbuf);
+ this->hidden->mixbuf = NULL;
if (this->hidden->stream) {
PULSEAUDIO_pa_stream_disconnect(this->hidden->stream);
PULSEAUDIO_pa_stream_unref(this->hidden->stream);
diff --git a/src/audio/qsa/SDL_qsa_audio.c b/src/audio/qsa/SDL_qsa_audio.c
index e3877b4..a5286d8 100644
--- a/src/audio/qsa/SDL_qsa_audio.c
+++ b/src/audio/qsa/SDL_qsa_audio.c
@@ -328,10 +328,8 @@ QSA_CloseDevice(_THIS)
this->hidden->audio_handle = NULL;
}
- if (this->hidden->pcm_buf != NULL) {
- SDL_FreeAudioMem(this->hidden->pcm_buf);
- this->hidden->pcm_buf = NULL;
- }
+ SDL_FreeAudioMem(this->hidden->pcm_buf);
+ this->hidden->pcm_buf = NULL;
SDL_free(this->hidden);
this->hidden = NULL;
diff --git a/src/audio/sndio/SDL_sndioaudio.c b/src/audio/sndio/SDL_sndioaudio.c
index 16d0ec3..309472d 100644
--- a/src/audio/sndio/SDL_sndioaudio.c
+++ b/src/audio/sndio/SDL_sndioaudio.c
@@ -181,10 +181,8 @@ static void
SNDIO_CloseDevice(_THIS)
{
if (this->hidden != NULL) {
- if (this->hidden->mixbuf != NULL) {
- SDL_FreeAudioMem(this->hidden->mixbuf);
- this->hidden->mixbuf = NULL;
- }
+ SDL_FreeAudioMem(this->hidden->mixbuf);
+ this->hidden->mixbuf = NULL;
if ( this->hidden->dev != NULL ) {
SNDIO_sio_close(this->hidden->dev);
this->hidden->dev = NULL;
diff --git a/src/audio/sun/SDL_sunaudio.c b/src/audio/sun/SDL_sunaudio.c
index 950ba44..98acf44 100644
--- a/src/audio/sun/SDL_sunaudio.c
+++ b/src/audio/sun/SDL_sunaudio.c
@@ -184,14 +184,10 @@ static void
SUNAUDIO_CloseDevice(_THIS)
{
if (this->hidden != NULL) {
- if (this->hidden->mixbuf != NULL) {
- SDL_FreeAudioMem(this->hidden->mixbuf);
- this->hidden->mixbuf = NULL;
- }
- if (this->hidden->ulaw_buf != NULL) {
- SDL_free(this->hidden->ulaw_buf);
- this->hidden->ulaw_buf = NULL;
- }
+ SDL_FreeAudioMem(this->hidden->mixbuf);
+ this->hidden->mixbuf = NULL;
+ SDL_free(this->hidden->ulaw_buf);
+ this->hidden->ulaw_buf = NULL;
if (this->hidden->audio_fd >= 0) {
close(this->hidden->audio_fd);
this->hidden->audio_fd = -1;
diff --git a/src/audio/winmm/SDL_winmm.c b/src/audio/winmm/SDL_winmm.c
index 9c8da7a..4220afd 100644
--- a/src/audio/winmm/SDL_winmm.c
+++ b/src/audio/winmm/SDL_winmm.c
@@ -176,11 +176,9 @@ WINMM_CloseDevice(_THIS)
}
}
- if (this->hidden->mixbuf != NULL) {
- /* Free raw mixing buffer */
- SDL_free(this->hidden->mixbuf);
- this->hidden->mixbuf = NULL;
- }
+ /* Free raw mixing buffer */
+ SDL_free(this->hidden->mixbuf);
+ this->hidden->mixbuf = NULL;
if (this->hidden->hin) {
waveInClose(this->hidden->hin);
diff --git a/src/audio/xaudio2/SDL_xaudio2.c b/src/audio/xaudio2/SDL_xaudio2.c
index 5af4b30..4f378ea 100644
--- a/src/audio/xaudio2/SDL_xaudio2.c
+++ b/src/audio/xaudio2/SDL_xaudio2.c
@@ -205,9 +205,7 @@ XAUDIO2_CloseDevice(_THIS)
if (ixa2 != NULL) {
IXAudio2_Release(ixa2);
}
- if (this->hidden->mixbuf != NULL) {
- SDL_free(this->hidden->mixbuf);
- }
+ SDL_free(this->hidden->mixbuf);
if (this->hidden->semaphore != NULL) {
CloseHandle(this->hidden->semaphore);
}
diff --git a/src/events/SDL_events.c b/src/events/SDL_events.c
index 06cb0f2..9213dae 100644
--- a/src/events/SDL_events.c
+++ b/src/events/SDL_events.c
@@ -141,10 +141,8 @@ SDL_StopEventLoop(void)
/* Clear disabled event state */
for (i = 0; i < SDL_arraysize(SDL_disabled_events); ++i) {
- if (SDL_disabled_events[i]) {
- SDL_free(SDL_disabled_events[i]);
- SDL_disabled_events[i] = NULL;
- }
+ SDL_free(SDL_disabled_events[i]);
+ SDL_disabled_events[i] = NULL;
}
while (SDL_event_watchers) {
diff --git a/src/events/SDL_touch.c b/src/events/SDL_touch.c
index 3429b57..1874ba7 100644
--- a/src/events/SDL_touch.c
+++ b/src/events/SDL_touch.c
@@ -355,10 +355,8 @@ SDL_TouchQuit(void)
}
SDL_assert(SDL_num_touch == 0);
- if (SDL_touchDevices) {
- SDL_free(SDL_touchDevices);
- SDL_touchDevices = NULL;
- }
+ SDL_free(SDL_touchDevices);
+ SDL_touchDevices = NULL;
}
/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/file/SDL_rwops.c b/src/file/SDL_rwops.c
index afbc39a..dc89e22 100644
--- a/src/file/SDL_rwops.c
+++ b/src/file/SDL_rwops.c
@@ -275,10 +275,8 @@ windows_file_close(SDL_RWops * context)
CloseHandle(context->hidden.windowsio.h);
context->hidden.windowsio.h = INVALID_HANDLE_VALUE; /* to be sure */
}
- if (context->hidden.windowsio.buffer.data) {
- SDL_free(context->hidden.windowsio.buffer.data);
- context->hidden.windowsio.buffer.data = NULL;
- }
+ SDL_free(context->hidden.windowsio.buffer.data);
+ context->hidden.windowsio.buffer.data = NULL;
SDL_FreeRW(context);
}
return (0);
diff --git a/src/filesystem/unix/SDL_sysfilesystem.c b/src/filesystem/unix/SDL_sysfilesystem.c
index acd3632..e1d06c4 100644
--- a/src/filesystem/unix/SDL_sysfilesystem.c
+++ b/src/filesystem/unix/SDL_sysfilesystem.c
@@ -69,9 +69,7 @@ readSymLink(const char *path)
len *= 2; /* grow buffer, try again. */
}
- if (retval != NULL) {
- SDL_free(retval);
- }
+ SDL_free(retval);
return NULL;
}
diff --git a/src/haptic/SDL_haptic.c b/src/haptic/SDL_haptic.c
index d7e1c50..33dd427 100644
--- a/src/haptic/SDL_haptic.c
+++ b/src/haptic/SDL_haptic.c
@@ -379,10 +379,8 @@ void
SDL_HapticQuit(void)
{
SDL_SYS_HapticQuit();
- if (SDL_haptics != NULL) {
- SDL_free(SDL_haptics);
- SDL_haptics = NULL;
- }
+ SDL_free(SDL_haptics);
+ SDL_haptics = NULL;
SDL_numhaptics = 0;
}
diff --git a/src/haptic/darwin/SDL_syshaptic.c b/src/haptic/darwin/SDL_syshaptic.c
index 8d9f17b..c999a77 100644
--- a/src/haptic/darwin/SDL_syshaptic.c
+++ b/src/haptic/darwin/SDL_syshaptic.c
@@ -943,14 +943,10 @@ SDL_SYS_HapticFreeFFEFFECT(FFEFFECT * effect, int type)
{
FFCUSTOMFORCE *custom;
- if (effect->lpEnvelope != NULL) {
- SDL_free(effect->lpEnvelope);
- effect->lpEnvelope = NULL;
- }
- if (effect->rgdwAxes != NULL) {
- SDL_free(effect->rgdwAxes);
- effect->rgdwAxes = NULL;
- }
+ SDL_free(effect->lpEnvelope);
+ effect->lpEnvelope = NULL;
+ SDL_free(effect->rgdwAxes);
+ effect->rgdwAxes = NULL;
if (effect->lpvTypeSpecificParams != NULL) {
if (type == SDL_HAPTIC_CUSTOM) { /* Must free the custom data. */
custom = (FFCUSTOMFORCE *) effect->lpvTypeSpecificParams;
@@ -960,10 +956,8 @@ SDL_SYS_HapticFreeFFEFFECT(FFEFFECT * effect, int type)
SDL_free(effect->lpvTypeSpecificParams);
effect->lpvTypeSpecificParams = NULL;
}
- if (effect->rglDirection != NULL) {
- SDL_free(effect->rglDirection);
- effect->rglDirection = NULL;
- }
+ SDL_free(effect->rglDirection);
+ effect->rglDirection = NULL;
}
@@ -1061,10 +1055,8 @@ SDL_SYS_HapticNewEffect(SDL_Haptic * haptic, struct haptic_effect *effect,
err_effectdone:
SDL_SYS_HapticFreeFFEFFECT(&effect->hweffect->effect, base->type);
err_hweffect:
- if (effect->hweffect != NULL) {
- SDL_free(effect->hweffect);
- effect->hweffect = NULL;
- }
+ SDL_free(effect->hweffect);
+ effect->hweffect = NULL;
return -1;
}
diff --git a/src/haptic/windows/SDL_syshaptic.c b/src/haptic/windows/SDL_syshaptic.c
index 5a393b3..f8b9096 100644
--- a/src/haptic/windows/SDL_syshaptic.c
+++ b/src/haptic/windows/SDL_syshaptic.c
@@ -751,10 +751,8 @@ SDL_SYS_HapticQuit(void)
}
for (i = 0; i < SDL_arraysize(SDL_hapticlist); ++i) {
- if (SDL_hapticlist[i].name) {
- SDL_free(SDL_hapticlist[i].name);
- SDL_hapticlist[i].name = NULL;
- }
+ SDL_free(SDL_hapticlist[i].name);
+ SDL_hapticlist[i].name = NULL;
}
if (dinput != NULL) {
@@ -1127,14 +1125,10 @@ SDL_SYS_HapticFreeDIEFFECT(DIEFFECT * effect, int type)
{
DICUSTOMFORCE *custom;
- if (effect->lpEnvelope != NULL) {
- SDL_free(effect->lpEnvelope);
- effect->lpEnvelope = NULL;
- }
- if (effect->rgdwAxes != NULL) {
- SDL_free(effect->rgdwAxes);
- effect->rgdwAxes = NULL;
- }
+ SDL_free(effect->lpEnvelope);
+ effect->lpEnvelope = NULL;
+ SDL_free(effect->rgdwAxes);
+ effect->rgdwAxes = NULL;
if (effect->lpvTypeSpecificParams != NULL) {
if (type == SDL_HAPTIC_CUSTOM) { /* Must free the custom data. */
custom = (DICUSTOMFORCE *) effect->lpvTypeSpecificParams;
@@ -1144,10 +1138,8 @@ SDL_SYS_HapticFreeDIEFFECT(DIEFFECT * effect, int type)
SDL_free(effect->lpvTypeSpecificParams);
effect->lpvTypeSpecificParams = NULL;
}
- if (effect->rglDirection != NULL) {
- SDL_free(effect->rglDirection);
- effect->rglDirection = NULL;
- }
+ SDL_free(effect->rglDirection);
+ effect->rglDirection = NULL;
}
@@ -1250,10 +1242,8 @@ SDL_SYS_HapticNewEffect(SDL_Haptic * haptic, struct haptic_effect *effect,
err_effectdone:
SDL_SYS_HapticFreeDIEFFECT(&effect->hweffect->effect, base->type);
err_hweffect:
- if (effect->hweffect != NULL) {
- SDL_free(effect->hweffect);
- effect->hweffect = NULL;
- }
+ SDL_free(effect->hweffect);
+ effect->hweffect = NULL;
return -1;
}
diff --git a/src/joystick/SDL_joystick.c b/src/joystick/SDL_joystick.c
index 4e08624..7309395 100644
--- a/src/joystick/SDL_joystick.c
+++ b/src/joystick/SDL_joystick.c
@@ -437,22 +437,13 @@ SDL_JoystickClose(SDL_Joystick * joystick)
joysticklist = joysticklist->next;
}
- if (joystick->name)
- SDL_free(joystick->name);
+ SDL_free(joystick->name);
/* Free the data associated with this joystick */
- if (joystick->axes) {
- SDL_free(joystick->axes);
- }
- if (joystick->hats) {
- SDL_free(joystick->hats);
- }
- if (joystick->balls) {
- SDL_free(joystick->balls);
- }
- if (joystick->buttons) {
- SDL_free(joystick->buttons);
- }
+ SDL_free(joystick->axes);
+ SDL_free(joystick->hats);
+ SDL_free(joystick->balls);
+ SDL_free(joystick->buttons);
SDL_free(joystick);
}
diff --git a/src/joystick/beos/SDL_bejoystick.cc b/src/joystick/beos/SDL_bejoystick.cc
index 4e342ed..c324581 100644
--- a/src/joystick/beos/SDL_bejoystick.cc
+++ b/src/joystick/beos/SDL_bejoystick.cc
@@ -231,12 +231,8 @@ extern "C"
if (joystick->hwdata) {
joystick->hwdata->stick->Close();
delete joystick->hwdata->stick;
- if (joystick->hwdata->new_hats) {
- SDL_free(joystick->hwdata->new_hats);
- }
- if (joystick->hwdata->new_axes) {
- SDL_free(joystick->hwdata->new_axes);
- }
+ SDL_free(joystick->hwdata->new_hats);
+ SDL_free(joystick->hwdata->new_axes);
SDL_free(joystick->hwdata);
joystick->hwdata = NULL;
}
diff --git a/src/joystick/bsd/SDL_sysjoystick.c b/src/joystick/bsd/SDL_sysjoystick.c
index 6d35d91..c5816b6 100644
--- a/src/joystick/bsd/SDL_sysjoystick.c
+++ b/src/joystick/bsd/SDL_sysjoystick.c
@@ -577,10 +577,8 @@ SDL_SYS_JoystickQuit(void)
int i;
for (i = 0; i < MAX_JOYS; i++) {
- if (joynames[i] != NULL)
- SDL_free(joynames[i]);
- if (joydevnames[i] != NULL)
- SDL_free(joydevnames[i]);
+ SDL_free(joynames[i]);
+ SDL_free(joydevnames[i]);
}
return;
@@ -657,9 +655,7 @@ report_alloc(struct report *r, struct report_desc *rd, int repind)
static void
report_free(struct report *r)
{
- if (r->buf != NULL) {
- SDL_free(r->buf);
- }
+ SDL_free(r->buf);
r->status = SREPORT_UNINIT;
}
diff --git a/src/joystick/windows/SDL_dxjoystick.c b/src/joystick/windows/SDL_dxjoystick.c
index 4165c70..54d54d2 100644
--- a/src/joystick/windows/SDL_dxjoystick.c
+++ b/src/joystick/windows/SDL_dxjoystick.c
@@ -834,7 +834,7 @@ void SDL_SYS_JoystickDetect()
pListNext = pCurList->pNext;
SDL_free(pCurList->joystickname);
- SDL_free( pCurList );
+ SDL_free(pCurList);
pCurList = pListNext;
}
@@ -1559,10 +1559,8 @@ SDL_SYS_JoystickClose(SDL_Joystick * joystick)
IDirectInputDevice8_Release(joystick->hwdata->InputDevice);
}
- if (joystick->hwdata != NULL) {
- /* free system specific hardware data */
- SDL_free(joystick->hwdata);
- }
+ /* free system specific hardware data */
+ SDL_free(joystick->hwdata);
joystick->closed = 1;
}
diff --git a/src/joystick/windows/SDL_mmjoystick.c b/src/joystick/windows/SDL_mmjoystick.c
index 413053f..f236dff 100644
--- a/src/joystick/windows/SDL_mmjoystick.c
+++ b/src/joystick/windows/SDL_mmjoystick.c
@@ -384,11 +384,9 @@ SDL_SYS_JoystickUpdate(SDL_Joystick * joystick)
void
SDL_SYS_JoystickClose(SDL_Joystick * joystick)
{
- if (joystick->hwdata != NULL) {
- /* free system specific hardware data */
- SDL_free(joystick->hwdata);
- joystick->hwdata = NULL;
- }
+ /* free system specific hardware data */
+ SDL_free(joystick->hwdata);
+ joystick->hwdata = NULL;
}
/* Function to perform any system-specific joystick related cleanup */
@@ -397,10 +395,8 @@ SDL_SYS_JoystickQuit(void)
{
int i;
for (i = 0; i < MAX_JOYSTICKS; i++) {
- if (SYS_JoystickName[i] != NULL) {
- SDL_free(SYS_JoystickName[i]);
- SYS_JoystickName[i] = NULL;
- }
+ SDL_free(SYS_JoystickName[i]);
+ SYS_JoystickName[i] = NULL;
}
}
diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c
index 5dfc38d..1e7f01f 100644
--- a/src/render/SDL_render.c
+++ b/src/render/SDL_render.c
@@ -1712,9 +1712,7 @@ SDL_DestroyTexture(SDL_Texture * texture)
if (texture->yuv) {
SDL_SW_DestroyYUVTexture(texture->yuv);
}
- if (texture->pixels) {
- SDL_free(texture->pixels);
- }
+ SDL_free(texture->pixels);
renderer->DestroyTexture(renderer, texture);
SDL_free(texture);
diff --git a/src/render/SDL_yuv_sw.c b/src/render/SDL_yuv_sw.c
index 46b680c..9604783 100644
--- a/src/render/SDL_yuv_sw.c
+++ b/src/render/SDL_yuv_sw.c
@@ -1335,15 +1335,9 @@ void
SDL_SW_DestroyYUVTexture(SDL_SW_YUVTexture * swdata)
{
if (swdata) {
- if (swdata->pixels) {
- SDL_free(swdata->pixels);
- }
- if (swdata->colortab) {
- SDL_free(swdata->colortab);
- }
- if (swdata->rgb_2_pix) {
- SDL_free(swdata->rgb_2_pix);
- }
+ SDL_free(swdata->pixels);
+ SDL_free(swdata->colortab);
+ SDL_free(swdata->rgb_2_pix);
if (swdata->stretch) {
SDL_FreeSurface(swdata->stretch);
}
diff --git a/src/render/direct3d/SDL_render_d3d.c b/src/render/direct3d/SDL_render_d3d.c
index 6e72b30..2ce2262 100644
--- a/src/render/direct3d/SDL_render_d3d.c
+++ b/src/render/direct3d/SDL_render_d3d.c
@@ -1813,9 +1813,7 @@ D3D_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
if (data->vtexture) {
IDirect3DTexture9_Release(data->vtexture);
}
- if (data->pixels) {
- SDL_free(data->pixels);
- }
+ SDL_free(data->pixels);
SDL_free(data);
texture->driverdata = NULL;
}
diff --git a/src/render/opengl/SDL_render_gl.c b/src/render/opengl/SDL_render_gl.c
index b1473b0..043e501 100644
--- a/src/render/opengl/SDL_render_gl.c
+++ b/src/render/opengl/SDL_render_gl.c
@@ -1318,9 +1318,7 @@ GL_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
renderdata->glDeleteTextures(1, &data->utexture);
renderdata->glDeleteTextures(1, &data->vtexture);
}
- if (data->pixels) {
- SDL_free(data->pixels);
- }
+ SDL_free(data->pixels);
SDL_free(data);
texture->driverdata = NULL;
}
diff --git a/src/render/opengles/SDL_render_gles.c b/src/render/opengles/SDL_render_gles.c
index 7f7d61a..1b3ea0f 100644
--- a/src/render/opengles/SDL_render_gles.c
+++ b/src/render/opengles/SDL_render_gles.c
@@ -573,9 +573,7 @@ GLES_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
data->format,
data->formattype,
src);
- if (blob) {
- SDL_free(blob);
- }
+ SDL_free(blob);
if (renderdata->glGetError() != GL_NO_ERROR)
{
@@ -1116,9 +1114,7 @@ GLES_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
if (data->texture) {
renderdata->glDeleteTextures(1, &data->texture);
}
- if (data->pixels) {
- SDL_free(data->pixels);
- }
+ SDL_free(data->pixels);
SDL_free(data);
texture->driverdata = NULL;
}
diff --git a/src/render/opengles2/SDL_render_gles2.c b/src/render/opengles2/SDL_render_gles2.c
index 83ead0a..db030c6 100644
--- a/src/render/opengles2/SDL_render_gles2.c
+++ b/src/render/opengles2/SDL_render_gles2.c
@@ -336,9 +336,7 @@ GLES2_DestroyRenderer(SDL_Renderer *renderer)
}
SDL_GL_DeleteContext(rdata->context);
}
- if (rdata->shader_formats) {
- SDL_free(rdata->shader_formats);
- }
+ SDL_free(rdata->shader_formats);
SDL_free(rdata);
}
SDL_free(renderer);
@@ -541,9 +539,7 @@ GLES2_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect
tdata->pixel_format,
tdata->pixel_type,
src);
- if (blob) {
- SDL_free(blob);
- }
+ SDL_free(blob);
if (rdata->glGetError() != GL_NO_ERROR) {
return SDL_SetError("Failed to update texture");
diff --git a/src/render/psp/SDL_render_psp.c b/src/render/psp/SDL_render_psp.c
index 5b10437..b8cd265 100644
--- a/src/render/psp/SDL_render_psp.c
+++ b/src/render/psp/SDL_render_psp.c
@@ -988,10 +988,7 @@ PSP_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture)
if(psp_texture == 0)
return;
- if(psp_texture->data != 0)
- {
- SDL_free(psp_texture->data);
- }
+ SDL_free(psp_texture->data);
SDL_free(psp_texture);
texture->driverdata = NULL;
}
diff --git a/src/render/software/SDL_render_sw.c b/src/render/software/SDL_render_sw.c
index 78f6ca1..348dd98 100644
--- a/src/render/software/SDL_render_sw.c
+++ b/src/render/software/SDL_render_sw.c
@@ -718,9 +718,7 @@ SW_DestroyRenderer(SDL_Renderer * renderer)
{
SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
- if (data) {
- SDL_free(data);
- }
+ SDL_free(data);
SDL_free(renderer);
}
diff --git a/src/stdlib/SDL_iconv.c b/src/stdlib/SDL_iconv.c
index 109e03e..4de2ebe 100644
--- a/src/stdlib/SDL_iconv.c
+++ b/src/stdlib/SDL_iconv.c
@@ -843,7 +843,7 @@ SDL_iconv(SDL_iconv_t cd,
int
SDL_iconv_close(SDL_iconv_t cd)
{
- if (cd && cd != (SDL_iconv_t) - 1) {
+ if (cd != (SDL_iconv_t)-1) {
SDL_free(cd);
}
return 0;
diff --git a/src/test/SDL_test_common.c b/src/test/SDL_test_common.c
index 14add55..3b2028a 100644
--- a/src/test/SDL_test_common.c
+++ b/src/test/SDL_test_common.c
@@ -1388,9 +1388,7 @@ SDLTest_CommonQuit(SDLTest_CommonState * state)
{
int i;
- if (state->windows) {
- SDL_free(state->windows);
- }
+ SDL_free(state->windows);
if (state->renderers) {
for (i = 0; i < state->num_windows; ++i) {
if (state->renderers[i]) {
diff --git a/src/video/SDL_RLEaccel.c b/src/video/SDL_RLEaccel.c
index 25ecd45..6db43b0 100644
--- a/src/video/SDL_RLEaccel.c
+++ b/src/video/SDL_RLEaccel.c
@@ -1558,10 +1558,8 @@ SDL_UnRLESurface(SDL_Surface * surface, int recode)
surface->map->info.flags &=
~(SDL_COPY_RLE_COLORKEY | SDL_COPY_RLE_ALPHAKEY);
- if (surface->map->data) {
- SDL_free(surface->map->data);
- surface->map->data = NULL;
- }
+ SDL_free(surface->map->data);
+ surface->map->data = NULL;
}
}
diff --git a/src/video/SDL_clipboard.c b/src/video/SDL_clipboard.c
index 83c2e34..cd1d341 100644
--- a/src/video/SDL_clipboard.c
+++ b/src/video/SDL_clipboard.c
@@ -35,9 +35,7 @@ SDL_SetClipboardText(const char *text)
if (_this->SetClipboardText) {
return _this->SetClipboardText(_this, text);
} else {
- if (_this->clipboard_text) {
- SDL_free(_this->clipboard_text);
- }
+ SDL_free(_this->clipboard_text);
_this->clipboard_text = SDL_strdup(text);
return 0;
}
diff --git a/src/video/SDL_pixels.c b/src/video/SDL_pixels.c
index c472c38..0300155 100644
--- a/src/video/SDL_pixels.c
+++ b/src/video/SDL_pixels.c
@@ -707,9 +707,7 @@ SDL_FreePalette(SDL_Palette * palette)
if (--palette->refcount > 0) {
return;
}
- if (palette->colors) {
- SDL_free(palette->colors);
- }
+ SDL_free(palette->colors);
SDL_free(palette);
}
@@ -985,10 +983,8 @@ SDL_InvalidateMap(SDL_BlitMap * map)
map->dst = NULL;
map->src_palette_version = 0;
map->dst_palette_version = 0;
- if (map->info.table) {
- SDL_free(map->info.table);
- map->info.table = NULL;
- }
+ SDL_free(map->info.table);
+ map->info.table = NULL;
}
int
diff --git a/src/video/SDL_surface.c b/src/video/SDL_surface.c
index ee1cf59..84d3a4d 100644
--- a/src/video/SDL_surface.c
+++ b/src/video/SDL_surface.c
@@ -1076,7 +1076,7 @@ SDL_FreeSurface(SDL_Surface * surface)
SDL_FreeBlitMap(surface->map);
surface->map = NULL;
}
- if (surface->pixels && ((surface->flags & SDL_PREALLOC) != SDL_PREALLOC)) {
+ if (!(surface->flags & SDL_PREALLOC)) {
SDL_free(surface->pixels);
}
SDL_free(surface);
diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c
index b98069c..dcf0494 100644
--- a/src/video/SDL_video.c
+++ b/src/video/SDL_video.c
@@ -263,10 +263,8 @@ SDL_CreateWindowTexture(_THIS, SDL_Window * window, Uint32 * format, void ** pix
SDL_DestroyTexture(data->texture);
data->texture = NULL;
}
- if (data->pixels) {
- SDL_free(data->pixels);
- data->pixels = NULL;
- }
+ SDL_free(data->pixels);
+ data->pixels = NULL;
if (SDL_GetRendererInfo(data->renderer, &info) < 0) {
return -1;
@@ -351,9 +349,7 @@ SDL_DestroyWindowTexture(_THIS, SDL_Window * window)
if (data->renderer) {
SDL_DestroyRenderer(data->renderer);
}
- if (data->pixels) {
- SDL_free(data->pixels);
- }
+ SDL_free(data->pixels);
SDL_free(data);
}
@@ -1407,9 +1403,7 @@ SDL_SetWindowTitle(SDL_Window * window, const char *title)
if (title == window->title) {
return;
}
- if (window->title) {
- SDL_free(window->title);
- }
+ SDL_free(window->title);
if (title && *title) {
window->title = SDL_strdup(title);
} else {
@@ -2188,15 +2182,11 @@ SDL_DestroyWindow(SDL_Window * window)
window->magic = NULL;
/* Free memory associated with the window */
- if (window->title) {
- SDL_free(window->title);
- }
+ SDL_free(window->title);
if (window->icon) {
SDL_FreeSurface(window->icon);
}
- if (window->gamma) {
- SDL_free(window->gamma);
- }
+ SDL_free(window->gamma);
while (window->data) {
SDL_WindowUserData *data = window->data;
@@ -2283,23 +2273,15 @@ SDL_VideoQuit(void)
for (i = 0; i < _this->num_displays; ++i) {
SDL_VideoDisplay *display = &_this->displays[i];
for (j = display->num_display_modes; j--;) {
- if (display->display_modes[j].driverdata) {
- SDL_free(display->display_modes[j].driverdata);
- display->display_modes[j].driverdata = NULL;
- }
- }
- if (display->display_modes) {
- SDL_free(display->display_modes);
- display->display_modes = NULL;
- }
- if (display->desktop_mode.driverdata) {
- SDL_free(display->desktop_mode.driverdata);
- display->desktop_mode.driverdata = NULL;
- }
- if (display->driverdata) {
- SDL_free(display->driverdata);
- display->driverdata = NULL;
+ SDL_free(display->display_modes[j].driverdata);
+ display->display_modes[j].driverdata = NULL;
}
+ SDL_free(display->display_modes);
+ display->display_modes = NULL;
+ SDL_free(display->desktop_mode.driverdata);
+ display->desktop_mode.driverdata = NULL;
+ SDL_free(display->driverdata);
+ display->driverdata = NULL;
}
if (_this->displays) {
for (i = 0; i < _this->num_displays; ++i) {
@@ -2309,10 +2291,8 @@ SDL_VideoQuit(void)
_this->displays = NULL;
_this->num_displays = 0;
}
- if (_this->clipboard_text) {
- SDL_free(_this->clipboard_text);
- _this->clipboard_text = NULL;
- }
+ SDL_free(_this->clipboard_text);
+ _this->clipboard_text = NULL;
_this->free(_this);
_this = NULL;
}
diff --git a/src/video/cocoa/SDL_cocoamodes.m b/src/video/cocoa/SDL_cocoamodes.m
index f10e7ee..d71cb17 100644
--- a/src/video/cocoa/SDL_cocoamodes.m
+++ b/src/video/cocoa/SDL_cocoamodes.m
@@ -281,7 +281,7 @@ Cocoa_InitModes(_THIS)
display.name = (char *)Cocoa_GetDisplayName(displays[i]);
if (!GetDisplayMode (_this, moderef, &mode)) {
Cocoa_ReleaseDisplayMode(_this, moderef);
- if (display.name) SDL_free(display.name);
+ SDL_free(display.name);
SDL_free(displaydata);
continue;
}
@@ -290,7 +290,7 @@ Cocoa_InitModes(_THIS)
display.current_mode = mode;
display.driverdata = displaydata;
SDL_AddVideoDisplay(&display);
- if (display.name) SDL_free(display.name);
+ SDL_free(display.name);
}
}
SDL_stack_free(displays);
diff --git a/src/video/cocoa/SDL_cocoavideo.m b/src/video/cocoa/SDL_cocoavideo.m
index 8499152..da71df0 100644
--- a/src/video/cocoa/SDL_cocoavideo.m
+++ b/src/video/cocoa/SDL_cocoavideo.m
@@ -71,9 +71,7 @@ Cocoa_CreateDevice(int devindex)
}
if (!data) {
SDL_OutOfMemory();
- if (device) {
- SDL_free(device);
- }
+ SDL_free(device);
return NULL;
}
device->driverdata = data;
diff --git a/src/video/directfb/SDL_DirectFB_render.c b/src/video/directfb/SDL_DirectFB_render.c
index d1cd49d..dc88646 100644
--- a/src/video/directfb/SDL_DirectFB_render.c
+++ b/src/video/directfb/SDL_DirectFB_render.c
@@ -1226,9 +1226,7 @@ DirectFB_DestroyRenderer(SDL_Renderer * renderer)
}
#endif
- if (data) {
- SDL_free(data);
- }
+ SDL_free(data);
SDL_free(renderer);
}
diff --git a/src/video/directfb/SDL_DirectFB_video.h b/src/video/directfb/SDL_DirectFB_video.h
index 53fcdcf..c3630fd 100644
--- a/src/video/directfb/SDL_DirectFB_video.h
+++ b/src/video/directfb/SDL_DirectFB_video.h
@@ -76,7 +76,7 @@
#define DFBENV_USE_WM "SDL_DIRECTFB_WM" /* Default: off */
#define SDL_DFB_RELEASE(x) do { if ( (x) != NULL ) { SDL_DFB_CHECK(x->Release(x)); x = NULL; } } while (0)
-#define SDL_DFB_FREE(x) do { if ( (x) != NULL ) { SDL_free(x); x = NULL; } } while (0)
+#define SDL_DFB_FREE(x) do { SDL_free((x)); (x) = NULL; } while (0)
#define SDL_DFB_UNLOCK(x) do { if ( (x) != NULL ) { x->Unlock(x); } } while (0)
#define SDL_DFB_CONTEXT "SDL_DirectFB"
diff --git a/src/video/dummy/SDL_nullvideo.c b/src/video/dummy/SDL_nullvideo.c
index 21f1124..9d6ea67 100644
--- a/src/video/dummy/SDL_nullvideo.c
+++ b/src/video/dummy/SDL_nullvideo.c
@@ -82,9 +82,7 @@ DUMMY_CreateDevice(int devindex)
device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
if (!device) {
SDL_OutOfMemory();
- if (device) {
- SDL_free(device);
- }
+ SDL_free(device);
return (0);
}
diff --git a/src/video/uikit/SDL_uikitvideo.m b/src/video/uikit/SDL_uikitvideo.m
index 662b109..74b24b8 100644
--- a/src/video/uikit/SDL_uikitvideo.m
+++ b/src/video/uikit/SDL_uikitvideo.m
@@ -63,9 +63,7 @@ UIKit_CreateDevice(int devindex)
/* Initialize all variables that we clean on shutdown */
device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
if (!device) {
- if (device) {
- SDL_free(device);
- }
+ SDL_free(device);
SDL_OutOfMemory();
return (0);
}
diff --git a/src/video/windows/SDL_windowsmessagebox.c b/src/video/windows/SDL_windowsmessagebox.c
index bbe7923..f544259 100644
--- a/src/video/windows/SDL_windowsmessagebox.c
+++ b/src/video/windows/SDL_windowsmessagebox.c
@@ -233,9 +233,7 @@ static SDL_bool AddDialogButton(WIN_DialogData *dialog, int x, int y, int w, int
static void FreeDialogData(WIN_DialogData *dialog)
{
- if (dialog->data) {
- SDL_free(dialog->data);
- }
+ SDL_free(dialog->data);
SDL_free(dialog);
}
diff --git a/src/video/windows/SDL_windowsvideo.c b/src/video/windows/SDL_windowsvideo.c
index 883cafa..77b63a2 100644
--- a/src/video/windows/SDL_windowsvideo.c
+++ b/src/video/windows/SDL_windowsvideo.c
@@ -75,9 +75,7 @@ WIN_CreateDevice(int devindex)
data = NULL;
}
if (!data) {
- if (device) {
- SDL_free(device);
- }
+ SDL_free(device);
SDL_OutOfMemory();
return NULL;
}
diff --git a/src/video/windows/SDL_windowswindow.c b/src/video/windows/SDL_windowswindow.c
index 94f555b..c28da52 100644
--- a/src/video/windows/SDL_windowswindow.c
+++ b/src/video/windows/SDL_windowswindow.c
@@ -319,9 +319,7 @@ WIN_SetWindowTitle(_THIS, SDL_Window * window)
title = NULL;
}
SetWindowText(hwnd, title ? title : TEXT(""));
- if (title) {
- SDL_free(title);
- }
+ SDL_free(title);
}
void
diff --git a/src/video/x11/SDL_x11opengl.c b/src/video/x11/SDL_x11opengl.c
index 6796b7d..6f1cc8b 100644
--- a/src/video/x11/SDL_x11opengl.c
+++ b/src/video/x11/SDL_x11opengl.c
@@ -267,10 +267,8 @@ X11_GL_UnloadLibrary(_THIS)
#endif
/* Free OpenGL memory */
- if (_this->gl_data) {
- SDL_free(_this->gl_data);
- _this->gl_data = NULL;
- }
+ SDL_free(_this->gl_data);
+ _this->gl_data = NULL;
}
static SDL_bool
diff --git a/src/video/x11/SDL_x11video.c b/src/video/x11/SDL_x11video.c
index 200e577..5ed47d5 100644
--- a/src/video/x11/SDL_x11video.c
+++ b/src/video/x11/SDL_x11video.c
@@ -565,9 +565,7 @@ X11_VideoQuit(_THIS)
{
SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
- if (data->classname) {
- SDL_free(data->classname);
- }
+ SDL_free(data->classname);
#ifdef X_HAVE_UTF8_STRING
if (data->im) {
XCloseIM(data->im);
diff --git a/test/testautomation.c b/test/testautomation.c
index 6610d8a..0a181bd 100644
--- a/test/testautomation.c
+++ b/test/testautomation.c
@@ -113,12 +113,8 @@ main(int argc, char *argv[])
}
/* Clean up */
- if (userRunSeed != NULL) {
- SDL_free(userRunSeed);
- }
- if (filter != NULL) {
- SDL_free(filter);
- }
+ SDL_free(userRunSeed);
+ SDL_free(filter);
/* Shutdown everything */
quit(result);
diff --git a/test/testautomation_audio.c b/test/testautomation_audio.c
index 50c1614..780c9e9 100644
--- a/test/testautomation_audio.c
+++ b/test/testautomation_audio.c
@@ -747,11 +747,9 @@ int audio_convertAudio()
SDLTest_AssertCheck(cvt.len_ratio > 0.0, "Verify conversion length ratio; expected: >0; got: %f", cvt.len_ratio);
/* Free converted buffer */
- if (cvt.buf != NULL) {
SDL_free(cvt.buf);
cvt.buf = NULL;
- }
- }
+ }
}
}
}
diff --git a/test/testautomation_clipboard.c b/test/testautomation_clipboard.c
index 92aec7d..1c438ee 100644
--- a/test/testautomation_clipboard.c
+++ b/test/testautomation_clipboard.c
@@ -41,7 +41,7 @@ clipboard_testGetClipboardText(void *arg)
charResult = SDL_GetClipboardText();
SDLTest_AssertPass("Call to SDL_GetClipboardText succeeded");
- if (charResult) SDL_free(charResult);
+ SDL_free(charResult);
return TEST_COMPLETED;
}
@@ -69,8 +69,8 @@ clipboard_testSetClipboardText(void *arg)
textRef, text);
/* Cleanup */
- if (textRef) SDL_free(textRef);
- if (text) SDL_free(text);
+ SDL_free(textRef);
+ SDL_free(text);
return TEST_COMPLETED;
}
@@ -145,9 +145,9 @@ clipboard_testClipboardTextFunctions(void *arg)
textRef, charResult);
/* Cleanup */
- if (textRef) SDL_free(textRef);
- if (text) SDL_free(text);
- if (charResult) SDL_free(charResult);
+ SDL_free(textRef);
+ SDL_free(text);
+ SDL_free(charResult);
return TEST_COMPLETED;
}
diff --git a/test/testautomation_render.c b/test/testautomation_render.c
index d582cb0..858679d 100644
--- a/test/testautomation_render.c
+++ b/test/testautomation_render.c
@@ -995,9 +995,7 @@ _compare(SDL_Surface *referenceSurface, int allowable_error)
SDLTest_AssertCheck(result == 0, "Validate result from SDLTest_CompareSurfaces, expected: 0, got: %i", result);
/* Clean up. */
- if (pixels != NULL) {
- SDL_free(pixels);
- }
+ SDL_free(pixels);
if (testSurface != NULL) {
SDL_FreeSurface(testSurface);
}
diff --git a/test/testautomation_video.c b/test/testautomation_video.c
index 350f0d0..3a7bfca 100644
--- a/test/testautomation_video.c
+++ b/test/testautomation_video.c
@@ -1714,10 +1714,10 @@ video_getSetWindowData(void *arg)
_destroyVideoSuiteTestWindow(window);
cleanup:
- if (referenceUserdata != NULL) SDL_free(referenceUserdata);
- if (referenceUserdata2 != NULL) SDL_free(referenceUserdata2);
- if (userdata != NULL) SDL_free(userdata);
- if (userdata2 != NULL) SDL_free(userdata2);
+ SDL_free(referenceUserdata);
+ SDL_free(referenceUserdata2);
+ SDL_free(userdata);
+ SDL_free(userdata2);
return returnValue;
}
diff --git a/test/testiconv.c b/test/testiconv.c
index 435e239..3165b34 100644
--- a/test/testiconv.c
+++ b/test/testiconv.c
@@ -75,12 +75,8 @@ main(int argc, char *argv[])
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "FAIL: %s\n", formats[i]);
++errors;
}
- if (test[0]) {
- SDL_free(test[0]);
- }
- if (test[1]) {
- SDL_free(test[1]);
- }
+ SDL_free(test[0]);
+ SDL_free(test[1]);
}
test[0] = SDL_iconv_string("UTF-8", "UCS-4", ucs4, len);
SDL_free(ucs4);
diff --git a/test/testsprite2.c b/test/testsprite2.c
index 26cc29f..b40efd3 100644
--- a/test/testsprite2.c
+++ b/test/testsprite2.c
@@ -42,15 +42,9 @@ static int iterations = -1;
static void
quit(int rc)
{
- if (sprites) {
- SDL_free(sprites);
- }
- if (positions) {
- SDL_free(positions);
- }
- if (velocities) {
- SDL_free(velocities);
- }
+ SDL_free(sprites);
+ SDL_free(positions);
+ SDL_free(velocities);
SDLTest_CommonQuit(state);
exit(rc);
}