]> git.alsa-project.org Git - alsa-lib.git/commitdiff
remove superfluous free() checks
authorClemens Ladisch <clemens@ladisch.de>
Mon, 27 Feb 2006 09:58:32 +0000 (09:58 +0000)
committerClemens Ladisch <clemens@ladisch.de>
Mon, 27 Feb 2006 09:58:32 +0000 (09:58 +0000)
free() correctly handles NULL pointers, so we can omit explicit checks
for that condition.

33 files changed:
src/alisp/alisp.c
src/conf.c
src/confmisc.c
src/control/control.c
src/control/control_shm.c
src/control/hcontrol.c
src/hwdep/hwdep.c
src/instr/iwffff.c
src/mixer/mixer.c
src/mixer/simple_abst.c
src/mixer/simple_none.c
src/names.c
src/pcm/pcm.c
src/pcm/pcm_adpcm.c
src/pcm/pcm_dmix.c
src/pcm/pcm_dshare.c
src/pcm/pcm_dsnoop.c
src/pcm/pcm_file.c
src/pcm/pcm_hw.c
src/pcm/pcm_ladspa.c
src/pcm/pcm_meter.c
src/pcm/pcm_multi.c
src/pcm/pcm_plug.c
src/pcm/pcm_route.c
src/pcm/pcm_share.c
src/pcm/pcm_shm.c
src/rawmidi/rawmidi.c
src/rawmidi/rawmidi_hw.c
src/rawmidi/rawmidi_virt.c
src/seq/seq.c
src/seq/seq_midi_event.c
src/timer/timer.c
src/timer/timer_query.c

index f15b9c77d2b096cdc026d562a56b980541c5c797..04db6c6ebaf734a2f399b833cc1a724ab3982618 100644 (file)
@@ -165,8 +165,7 @@ static void free_object(struct alisp_object * p)
        switch (alisp_get_type(p)) {
        case ALISP_OBJ_STRING:
        case ALISP_OBJ_IDENTIFIER:
-               if (p->value.s)
-                       free(p->value.s);
+               free(p->value.s);
                alisp_set_type(p, ALISP_OBJ_INTEGER);
                break;
        default:
@@ -523,8 +522,7 @@ static int init_lex(struct alisp_instance *instance)
 
 static void done_lex(struct alisp_instance *instance)
 {
-       if (instance->token_buffer)
-               free(instance->token_buffer);
+       free(instance->token_buffer);
 }
 
 static char * extend_buf(struct alisp_instance *instance, char *p)
@@ -1184,8 +1182,7 @@ static struct alisp_object * F_concat(struct alisp_instance *instance, struct al
                        str1 = realloc(str, (str ? strlen(str) : 0) + strlen(p1->value.s) + 1);
                        if (str1 == NULL) {
                                nomem();
-                               if (str)
-                                       free(str);
+                               free(str);
                                return NULL;
                        }
                        if (str == NULL)
@@ -2366,8 +2363,7 @@ static struct alisp_object * eval_func(struct alisp_instance *instance, struct a
                }
 
                _end:
-               if (eval_objs)
-                       free(eval_objs);
+               free(eval_objs);
 
                return p4;
        } else {
index 3667ac065b7cb4c0dd09b32caa85f1e5cbc546af..10555328c0625e89c284f67722286018c828ffb8 100644 (file)
@@ -980,8 +980,7 @@ static int parse_value(snd_config_t **_n, snd_config_t *father, input_t *input,
                if (err < 0)
                        return err;
        }
-       if (n->u.string)
-               free(n->u.string);
+       free(n->u.string);
        n->u.string = s;
        *_n = n;
        return 0;
@@ -1056,8 +1055,7 @@ static int parse_array_def(snd_config_t *father, input_t *input, int idx, int sk
        }
        err = 0;
       __end:
-       if (id)
-               free(id);
+       free(id);
        return err;
 }
 
@@ -1218,8 +1216,7 @@ static int parse_def(snd_config_t *father, input_t *input, int skip, int overrid
                unget_char(c, input);
        }
       __end:
-       if (id)
-               free(id);
+       free(id);
        return err;
 }
                
@@ -1446,8 +1443,7 @@ int snd_config_substitute(snd_config_t *dst, snd_config_t *src)
                if (err < 0)
                        return err;
        }
-       if (dst->id)
-               free(dst->id);
+       free(dst->id);
        dst->id = src->id;
        dst->type = src->type;
        dst->u = src->u;
@@ -1528,8 +1524,7 @@ int snd_config_set_id(snd_config_t *config, const char *id)
        new_id = strdup(id);
        if (!new_id)
                return -ENOMEM;
-       if (config->id)
-               free(config->id);
+       free(config->id);
        config->id = new_id;
        return 0;
 }
@@ -1696,16 +1691,14 @@ int snd_config_delete(snd_config_t *config)
                break;
        }
        case SND_CONFIG_TYPE_STRING:
-               if (config->u.string)
-                       free(config->u.string);
+               free(config->u.string);
                break;
        default:
                break;
        }
        if (config->father)
                list_del(&config->list);
-       if (config->id)
-               free(config->id);
+       free(config->id);
        free(config);
        return 0;
 }
@@ -2023,8 +2016,7 @@ int snd_config_set_string(snd_config_t *config, const char *value)
        } else {
                new_string = NULL;
        }
-       if (config->u.string)
-               free(config->u.string);
+       free(config->u.string);
        config->u.string = new_string;
        return 0;
 }
@@ -2091,8 +2083,7 @@ int snd_config_set_ascii(snd_config_t *config, const char *ascii)
                        char *ptr = strdup(ascii);
                        if (ptr == NULL)
                                return -ENOMEM;
-                       if (config->u.string)
-                               free(config->u.string);
+                       free(config->u.string);
                        config->u.string = ptr;
                }
                break;
@@ -2702,8 +2693,7 @@ static int snd_config_hooks_call(snd_config_t *root, snd_config_t *config, snd_c
                if (err >= 0 && nroot)
                        err = snd_config_substitute(root, nroot);
        }
-       if (buf)
-               free(buf);
+       free(buf);
        if (err < 0)
                return err;
        return 0;
@@ -2844,11 +2834,10 @@ int snd_config_hook_load(snd_config_t *root, snd_config_t *config, snd_config_t
        *dst = NULL;
        err = 0;
        _err:
-       for (idx = 0; idx < fi_count; idx++)
-                       if (fi[idx].name)
-                               free(fi[idx].name);
-               if (fi)
-                       free(fi);
+       if (fi)
+               for (idx = 0; idx < fi_count; idx++)
+                       free(fi[idx].name);
+       free(fi);
        snd_config_delete(n);
        return err;
 }
@@ -2905,8 +2894,7 @@ int snd_config_hook_load_for_all_cards(snd_config_t *root, snd_config_t *config,
                      __err:
                        if (private_data)
                                snd_config_delete(private_data);
-                       if (fdriver)
-                               free(fdriver);
+                       free(fdriver);
                        if (err < 0)
                                return err;
                }
@@ -3108,8 +3096,7 @@ int snd_config_update_free(snd_config_update_t *update)
        assert(update);
        for (k = 0; k < update->count; k++)
                free(update->finfo[k].name);
-       if (update->finfo)
-               free(update->finfo);
+       free(update->finfo);
        free(update);
        return 0;
 }
@@ -3500,8 +3487,7 @@ static int _snd_config_evaluate(snd_config_t *src,
                        }
                }
               _errbuf:
-               if (buf)
-                       free(buf);
+               free(buf);
                if (err < 0)
                        return err;
                return 0;
index 2b5efb1424a2ff3dc6f2d4f65e29682d81aa9ff2..147ca647847228c937a81bbfe2f67c0ac422c9f0 100644 (file)
@@ -295,8 +295,7 @@ int snd_func_getenv(snd_config_t **dst, snd_config_t *root, snd_config_t *src,
                free(res);
        }
       __error:
-       if (def)
-               free(def);
+       free(def);
        return err;
 }
 #ifndef DOC_HIDDEN
@@ -419,8 +418,7 @@ int snd_func_concat(snd_config_t **dst, snd_config_t *root, snd_config_t *src,
                                tmp = realloc(res, len + len1 + 1);
                                if (tmp == NULL) {
                                        free(ptr);
-                                       if (res)
-                                               free(res);
+                                       free(res);
                                        err = -ENOMEM;
                                        goto __error;
                                }
index cb4d92be889838242ac447f194d015cc0a1fdad1..4bf96e57ea831ee130c93dd11bf38370181721ec 100644 (file)
@@ -94,8 +94,7 @@ int snd_ctl_close(snd_ctl_t *ctl)
                snd_async_del_handler(h);
        }
        err = ctl->ops->close(ctl);
-       if (ctl->name)
-               free(ctl->name);
+       free(ctl->name);
        if (ctl->dl_handle)
                snd_dlclose(ctl->dl_handle);
        free(ctl);
@@ -925,8 +924,7 @@ const char *snd_ctl_event_type_name(snd_ctl_event_type_t type)
  */
 int snd_ctl_elem_list_alloc_space(snd_ctl_elem_list_t *obj, unsigned int entries)
 {
-       if (obj->pids)
-               free(obj->pids);
+       free(obj->pids);
        obj->pids = calloc(entries, sizeof(*obj->pids));
        if (!obj->pids) {
                obj->space = 0;
index 903be396ac2c4644f8686ec22b0b76e3b41b3534..fbb123666c41f6fa529866ae1c6b5fdc21eb7bec 100644 (file)
@@ -555,8 +555,7 @@ int snd_ctl_shm_open(snd_ctl_t **handlep, const char *name, const char *sockname
        close(sock);
        if (ctrl)
                shmdt(ctrl);
-       if (shm)
-               free(shm);
+       free(shm);
        return result;
 }
 
index 635f526f8e17af1536e50cb5ace4d43a43fc4ad7..5d20e7400b44100e06ad333867724a44eaf7d0a9 100644 (file)
@@ -606,8 +606,7 @@ int snd_hctl_load(snd_hctl_t *hctl)
        }
        err = snd_ctl_subscribe_events(hctl->ctl, 1);
  _end:
-       if (list.pids)
-               free(list.pids);
+       free(list.pids);
        return err;
 }
 
index 6a5e7872b3c55c03d1c89e7074d2412ca60876f0..4d4490cd14aee80069a9dd7b4b36141b9f0b6c1a 100644 (file)
@@ -207,8 +207,7 @@ int snd_hwdep_close(snd_hwdep_t *hwdep)
        int err;
        assert(hwdep);
        err = hwdep->ops->close(hwdep);
-       if (hwdep->name)
-               free(hwdep->name);
+       free(hwdep->name);
        free(hwdep);
        return err;
 }
index 637045bc59214c55c24b713989194045c10e7772..7f15ed03a5d208fff7a6896eb39f5577d87d26d7 100644 (file)
@@ -382,12 +382,9 @@ int snd_instr_iwffff_close(snd_iwffff_handle_t *handle)
 {
        if (handle == NULL)
                return -EINVAL;
-       if (handle->dat_filename)
-               free(handle->dat_filename);
-       if (handle->fff_filename)
-               free(handle->fff_filename);
-       if (handle->fff_data)
-               free(handle->fff_data);
+       free(handle->dat_filename);
+       free(handle->fff_filename);
+       free(handle->fff_data);
        free(handle);
        return 0;
 }
@@ -396,8 +393,7 @@ static void free_wave(iwffff_wave_t *wave)
 {
        if (wave == NULL)
                return;
-       if (wave->address.ptr != NULL)
-               free(wave->address.ptr);
+       free(wave->address.ptr);
        free(wave);
 }
 
index 5ef0ba79f11bbfa9803ade762fd5a604055215ec..d2edeea8e4d06933c9229262bc2271a8f62df5ac 100644 (file)
@@ -607,10 +607,8 @@ int snd_mixer_close(snd_mixer_t *mixer)
        }
        assert(list_empty(&mixer->elems));
        assert(mixer->count == 0);
-       if (mixer->pelems) {
-               free(mixer->pelems);
-               mixer->pelems = NULL;
-       }
+       free(mixer->pelems);
+       mixer->pelems = NULL;
        while (!list_empty(&mixer->slaves)) {
                int err;
                snd_mixer_slave_t *s;
index 789216dc2fdce416a5c1b9cf607516be8ffd358c..45aedb0566af015cd88b1019108d7b961f16287b 100644 (file)
@@ -182,8 +182,7 @@ static void private_free(snd_mixer_class_t *class)
                snd_hctl_close(priv->hctl);
        } else if (priv->ctl)
                snd_ctl_close(priv->ctl);
-       if (priv->device)
-               free(priv->device);
+       free(priv->device);
        free(priv);
 }
 
index fdb57f44c35904887bda756a4fc1f5bbddb88b50..43563167f0e51bd65e8404c9551f45efdf66bdf1 100644 (file)
@@ -1388,8 +1388,7 @@ int snd_mixer_simple_none_register(snd_mixer_t *mixer,
        snd_mixer_class_set_compare(class, snd_mixer_selem_compare);
        err = snd_mixer_class_register(class, mixer);
        if (err < 0) {
-               if (class)
-                       free(class);
+               free(class);
                return err;
        }
        if (classp)
index dbbdaa909a5dff4537fec0521f3642a464cf443a..652477af51c6d1d9f91d47c89252ee9a499925cb 100644 (file)
@@ -105,17 +105,14 @@ static int names_parse(snd_config_t *top, const char *iface, snd_devname_t **lis
                        }
                        last = dn;
                } else {
-                       if (comment != NULL)
-                               free(comment);
+                       free(comment);
                }
        }
        return 0;
 
        _err:
-       if (name)
-               free(name);
-       if (comment)
-               free(comment);
+       free(name);
+       free(comment);
        return err;
 }
 
@@ -189,10 +186,8 @@ void snd_names_list_free(snd_devname_t *list)
        
        while (list != NULL) {
                next = list->next;
-               if (list->name)
-                       free(list->name);
-               if (list->comment)
-                       free(list->comment);
+               free(list->name);
+               free(list->comment);
                free(list);
                list = next;
        }
index 0af6f2aacc4f389333deb6f134eb5b81bd4587bf..47f3501f3dfaa8b395c469b4ac8038babf89eb0b 100644 (file)
@@ -2102,10 +2102,8 @@ static int snd_pcm_open_conf(snd_pcm_t **pcmp, const char *name,
        }
        if (type_conf)
                snd_config_delete(type_conf);
-       if (buf)
-               free(buf);
-       if (buf1)
-               free(buf1);
+       free(buf);
+       free(buf1);
        return err;
 }
 
@@ -2187,12 +2185,9 @@ int snd_pcm_new(snd_pcm_t **pcmp, snd_pcm_type_t type, const char *name,
 int snd_pcm_free(snd_pcm_t *pcm)
 {
        assert(pcm);
-       if (pcm->name)
-               free(pcm->name);
-       if (pcm->hw.link_dst)
-               free(pcm->hw.link_dst);
-       if (pcm->appl.link_dst)
-               free(pcm->appl.link_dst);
+       free(pcm->name);
+       free(pcm->hw.link_dst);
+       free(pcm->appl.link_dst);
        if (pcm->dl_handle)
                snd_dlclose(pcm->dl_handle);
        free(pcm);
index 8350dbec4c5bbe7a5e3c71c3356aa6501515165c..416c37f4c54626a73bfe039f3532509f4ba5a301 100644 (file)
@@ -449,10 +449,8 @@ static int snd_pcm_adpcm_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params)
 static int snd_pcm_adpcm_hw_free(snd_pcm_t *pcm)
 {
        snd_pcm_adpcm_t *adpcm = pcm->private_data;
-       if (adpcm->states) {
-               free(adpcm->states);
-               adpcm->states = 0;
-       }
+       free(adpcm->states);
+       adpcm->states = NULL;
        return snd_pcm_hw_free(adpcm->plug.gen.slave);
 }
 
index 41a6bd8feadeb6b3fd4b8b2279a6a38c460f3cb0..ed500b8548ffa5de227eb0687a90f0d958e62007 100644 (file)
@@ -639,8 +639,7 @@ static int snd_pcm_dmix_close(snd_pcm_t *pcm)
        shm_sum_discard(dmix);
        snd_pcm_direct_shm_discard(dmix);
        snd_pcm_direct_semaphore_up(dmix, DIRECT_IPC_SEM_CLIENT);
-       if (dmix->bindings)
-               free(dmix->bindings);
+       free(dmix->bindings);
        pcm->private_data = NULL;
        free(dmix);
        return 0;
@@ -941,8 +940,7 @@ int snd_pcm_dmix_open(snd_pcm_t **pcmp, const char *name,
                snd_pcm_direct_semaphore_up(dmix, DIRECT_IPC_SEM_CLIENT);
  _err_nosem:
        if (dmix) {
-               if (dmix->bindings)
-                       free(dmix->bindings);
+               free(dmix->bindings);
                free(dmix);
        }
        if (pcm)
index 2d719dc93589c13b7986a36d52aab30524b09f03..d54b403126c45e2813a72497fd82bc15ba49a4a7 100644 (file)
@@ -466,8 +466,7 @@ static int snd_pcm_dshare_close(snd_pcm_t *pcm)
                snd_pcm_direct_client_discard(dshare);
        snd_pcm_direct_shm_discard(dshare);
        snd_pcm_direct_semaphore_up(dshare, DIRECT_IPC_SEM_CLIENT);
-       if (dshare->bindings)
-               free(dshare->bindings);
+       free(dshare->bindings);
        pcm->private_data = NULL;
        free(dshare);
        return 0;
@@ -763,8 +762,7 @@ int snd_pcm_dshare_open(snd_pcm_t **pcmp, const char *name,
                snd_pcm_direct_semaphore_up(dshare, DIRECT_IPC_SEM_CLIENT);
  _err_nosem:
        if (dshare) {
-               if (dshare->bindings)
-                       free(dshare->bindings);
+               free(dshare->bindings);
                free(dshare);
        }
        if (pcm)
index d3a2a0b8bcde5ea240e86fbce7a4d472be5426fe..fbb9d0464a1254fd0eff64af102e32d3315ecd36 100644 (file)
@@ -362,8 +362,7 @@ static int snd_pcm_dsnoop_close(snd_pcm_t *pcm)
                snd_pcm_direct_client_discard(dsnoop);
        snd_pcm_direct_shm_discard(dsnoop);
        snd_pcm_direct_semaphore_up(dsnoop, DIRECT_IPC_SEM_CLIENT);
-       if (dsnoop->bindings)
-               free(dsnoop->bindings);
+       free(dsnoop->bindings);
        pcm->private_data = NULL;
        free(dsnoop);
        return 0;
@@ -636,8 +635,7 @@ int snd_pcm_dsnoop_open(snd_pcm_t **pcmp, const char *name,
                snd_pcm_direct_semaphore_up(dsnoop, DIRECT_IPC_SEM_CLIENT);
  _err_nosem:
        if (dsnoop) {
-               if (dsnoop->bindings)
-                       free(dsnoop->bindings);
+               free(dsnoop->bindings);
                free(dsnoop);
        }
        if (pcm)
index 18951cc298bd0aff992fb778a64bbe9c9d2182d7..9e41961366bb57ee0b83626e0dc425483401e19b 100644 (file)
@@ -263,13 +263,10 @@ static snd_pcm_sframes_t snd_pcm_file_mmap_commit(snd_pcm_t *pcm,
 static int snd_pcm_file_hw_free(snd_pcm_t *pcm)
 {
        snd_pcm_file_t *file = pcm->private_data;
-       if (file->wbuf) {
-               free(file->wbuf);
-               if (file->wbuf_areas)
-                       free(file->wbuf_areas);
-               file->wbuf = 0;
-               file->wbuf_areas = 0;
-       }
+       free(file->wbuf);
+       free(file->wbuf_areas);
+       file->wbuf = NULL;
+       file->wbuf_areas = NULL;
        return snd_pcm_hw_free(file->gen.slave);
 }
 
@@ -418,8 +415,7 @@ int snd_pcm_file_open(snd_pcm_t **pcmp, const char *name,
 
        err = snd_pcm_new(&pcm, SND_PCM_TYPE_FILE, name, slave->stream, slave->mode);
        if (err < 0) {
-               if (fname)
-                       free(file->fname);
+               free(file->fname);
                free(file);
                return err;
        }
index 356576fa1570b9faac92114271af8b372be18e61..ef725d26169f0f8f3f8bf1168efefed83180979a 100644 (file)
@@ -843,10 +843,8 @@ static int snd_pcm_hw_munmap_status(snd_pcm_t *pcm)
        snd_pcm_hw_t *hw = pcm->private_data;
        int err;
        if (hw->sync_ptr_ioctl) {
-               if (hw->sync_ptr) {
-                       free(hw->sync_ptr);
-                       hw->sync_ptr = NULL;
-               }
+               free(hw->sync_ptr);
+               hw->sync_ptr = NULL;
        } else {
                if (munmap((void*)hw->mmap_status, page_align(sizeof(*hw->mmap_status))) < 0) {
                        err = -errno;
@@ -862,10 +860,8 @@ static int snd_pcm_hw_munmap_control(snd_pcm_t *pcm)
        snd_pcm_hw_t *hw = pcm->private_data;
        int err;
        if (hw->sync_ptr_ioctl) {
-               if (hw->sync_ptr) {
-                       free(hw->sync_ptr);
-                       hw->sync_ptr = NULL;
-               }
+               free(hw->sync_ptr);
+               hw->sync_ptr = NULL;
        } else {
                if (munmap(hw->mmap_control, page_align(sizeof(*hw->mmap_control))) < 0) {
                        err = -errno;
index d4432ae3843f9544337236066b588779257144aa..52296c052197092434f070ff78785e6b5e31e43c 100644 (file)
@@ -175,10 +175,8 @@ static int snd_pcm_ladspa_find_port_idx(unsigned int *res,
 
 static void snd_pcm_ladspa_free_io(snd_pcm_ladspa_plugin_io_t *io)
 {
-        if (io->controls)
-                free(io->controls);
-        if (io->controls_initialized)
-                free(io->controls_initialized);
+       free(io->controls);
+       free(io->controls_initialized);
 }
 
 static void snd_pcm_ladspa_free_plugins(struct list_head *plugins)
@@ -189,8 +187,7 @@ static void snd_pcm_ladspa_free_plugins(struct list_head *plugins)
                 snd_pcm_ladspa_free_io(&plugin->output);
                if (plugin->dl_handle)
                        dlclose(plugin->dl_handle);
-               if (plugin->filename)
-                       free(plugin->filename);
+               free(plugin->filename);
                list_del(&plugin->list);
                free(plugin);
        }
@@ -203,8 +200,7 @@ static void snd_pcm_ladspa_free(snd_pcm_ladspa_t *ladspa)
        snd_pcm_ladspa_free_plugins(&ladspa->pplugins);
        snd_pcm_ladspa_free_plugins(&ladspa->cplugins);
        for (idx = 0; idx < 2; idx++) {
-               if (ladspa->zero[idx])
-                       free(ladspa->zero[idx]);
+               free(ladspa->zero[idx]);
                 ladspa->zero[idx] = NULL;
         }
         ladspa->allocated = 0;
@@ -317,10 +313,8 @@ static int snd_pcm_ladspa_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t * params
 
 static void snd_pcm_ladspa_free_eps(snd_pcm_ladspa_eps_t *eps)
 {
-       if (eps->channels.array)
-               free(eps->channels.array);
-        if (eps->ports.array)
-                free(eps->ports.array);
+       free(eps->channels.array);
+       free(eps->ports.array);
 }
 
 static void snd_pcm_ladspa_free_instances(snd_pcm_t *pcm, snd_pcm_ladspa_t *ladspa, int cleanup)
@@ -340,14 +334,12 @@ static void snd_pcm_ladspa_free_instances(snd_pcm_t *pcm, snd_pcm_ladspa_t *lads
                                        plugin->desc->cleanup(instance->handle);
                                if (instance->input.m_data) {
                                        for (idx = 0; idx < instance->input.channels.size; idx++)
-                                               if (instance->input.m_data[idx])
-                                                       free(instance->input.m_data[idx]);
+                                               free(instance->input.m_data[idx]);
                                        free(instance->input.m_data);
                                 }
                                if (instance->output.m_data) {
                                        for (idx = 0; idx < instance->output.channels.size; idx++)
-                                               if (instance->output.m_data[idx])
-                                                       free(instance->output.m_data[idx]);
+                                               free(instance->output.m_data[idx]);
                                        free(instance->output.m_data);
                                 }
                                list_del(&(instance->list));
@@ -789,10 +781,8 @@ static int snd_pcm_ladspa_allocate_memory(snd_pcm_t *pcm, snd_pcm_ladspa_t *lads
                         for (idx = 0; idx < instance->output.channels.size; idx++) {
                                chn = instance->output.channels.array[idx];
                                 if (instance->output.data[idx] == pchannels[chn]) {
-                                        if (instance->output.m_data[idx]) {
-                                                free(instance->output.m_data[idx]);
-                                                instance->output.m_data[idx] = NULL;
-                                        }
+                                       free(instance->output.m_data[idx]);
+                                       instance->output.m_data[idx] = NULL;
                                         if (chn < ochannels) {
                                                 instance->output.data[idx] = NULL;
                                         } else {
index b84747c4b97435c8f4e0bdf95e8e7ef2f492a7fe..8ff5d831d39fee2df2de530056e6a99bb58a580e 100644 (file)
@@ -153,8 +153,7 @@ static int snd_pcm_meter_update_scope(snd_pcm_t *pcm)
 
 static int snd_pcm_scope_remove(snd_pcm_scope_t *scope)
 {
-       if (scope->name)
-               free((void *)scope->name);
+       free(scope->name);
        scope->ops->close(scope);
        list_del(&scope->list);
        free(scope);
@@ -480,12 +479,10 @@ static int snd_pcm_meter_hw_free(snd_pcm_t *pcm)
        pthread_mutex_unlock(&meter->running_mutex);
        err = pthread_join(meter->thread, 0);
        assert(err == 0);
-       if (meter->buf) {
-               free(meter->buf);
-               free(meter->buf_areas);
-               meter->buf = 0;
-               meter->buf_areas = 0;
-       }
+       free(meter->buf);
+       free(meter->buf_areas);
+       meter->buf = NULL;
+       meter->buf_areas = NULL;
        return snd_pcm_hw_free(meter->gen.slave);
 }
 
@@ -1028,15 +1025,13 @@ static int s16_enable(snd_pcm_scope_t *scope)
        }
        s16->buf = malloc(meter->buf_size * 2 * spcm->channels);
        if (!s16->buf) {
-               if (s16->adpcm_states)
-                       free(s16->adpcm_states);
+               free(s16->adpcm_states);
                return -ENOMEM;
        }
        a = calloc(spcm->channels, sizeof(*a));
        if (!a) {
                free(s16->buf);
-               if (s16->adpcm_states)
-                       free(s16->adpcm_states);
+               free(s16->adpcm_states);
                return -ENOMEM;
        }
        s16->buf_areas = a;
@@ -1051,10 +1046,8 @@ static int s16_enable(snd_pcm_scope_t *scope)
 static void s16_disable(snd_pcm_scope_t *scope)
 {
        snd_pcm_scope_s16_t *s16 = scope->private_data;
-       if (s16->adpcm_states) {
-               free(s16->adpcm_states);
-               s16->adpcm_states = NULL;
-       }
+       free(s16->adpcm_states);
+       s16->adpcm_states = NULL;
        free(s16->buf);
        s16->buf = NULL;
        free(s16->buf_areas);
index 9c492f95a9818a6837f60799a79fcd7c5ec76e06..22bfd9a43e0ddf924abe7fd98bd69f40a16dad29 100644 (file)
@@ -790,7 +790,7 @@ int snd_pcm_multi_open(snd_pcm_t **pcmp, const char *name,
        multi->channels = calloc(channels_count, sizeof(*multi->channels));
        if (!multi->channels) {
                free(multi->slaves);
-               free(multi->channels);
+               free(multi);
                return -ENOMEM;
        }
        for (i = 0; i < slaves_count; ++i) {
@@ -1130,16 +1130,11 @@ _free:
                }
                free(slaves_conf);
        }
-       if (slaves_pcm)
-               free(slaves_pcm);
-       if (slaves_channels)
-               free(slaves_channels);
-       if (channels_sidx)
-               free(channels_sidx);
-       if (channels_schannel)
-               free(channels_schannel);
-       if (slaves_id)
-               free(slaves_id);
+       free(slaves_pcm);
+       free(slaves_channels);
+       free(channels_sidx);
+       free(channels_schannel);
+       free(slaves_id);
        return err;
 }
 #ifndef DOC_HIDDEN
index 15204d7586ad1847f17c31a72a358ee1117a90d5..98ee68357015b371e4fc7f361c3fcc8b4fe334de 100644 (file)
@@ -62,8 +62,7 @@ static int snd_pcm_plug_close(snd_pcm_t *pcm)
 {
        snd_pcm_plug_t *plug = pcm->private_data;
        int err, result = 0;
-       if (plug->ttable)
-               free(plug->ttable);
+       free(plug->ttable);
        assert(plug->gen.slave == plug->req_slave);
        if (plug->gen.close_slave) {
                snd_pcm_unlink_hw_ptr(pcm, plug->req_slave);
index daddf7c743d89d1bd6b9b63546eb771221010431..a7f7699b6b084d4abd21c8b592b86dd42dd345e0 100644 (file)
@@ -513,8 +513,7 @@ static int snd_pcm_route_close(snd_pcm_t *pcm)
 
        if (params->dsts) {
                for (dst_channel = 0; dst_channel < params->ndsts; ++dst_channel) {
-                       if (params->dsts[dst_channel].srcs != NULL)
-                               free(params->dsts[dst_channel].srcs);
+                       free(params->dsts[dst_channel].srcs);
                }
                free(params->dsts);
        }
index d73fb8b2a9f1c406729ab107b4e2480a7206ba97..cc65907d5d505b62117cdad2ad10f02cd6cc8de9 100644 (file)
@@ -1689,10 +1689,8 @@ int _snd_pcm_share_open(snd_pcm_t **pcmp, const char *name,
                                 speriod_time, sbuffer_time,
                                 channels, channels_map, stream, mode);
 _free:
-       if (channels_map)
-               free(channels_map);
-       if (sname)
-               free((char *)sname);
+       free(channels_map);
+       free((char *)sname);
        return err;
 }
 #ifndef DOC_HIDDEN
index 0640c4bb4238d87d042d09b517a0e0f2ad679bb8..c94396614cbb5440e4655a01656a3a637c2ff284 100644 (file)
@@ -773,8 +773,7 @@ int snd_pcm_shm_open(snd_pcm_t **pcmp, const char *name,
        close(sock);
        if (ctrl)
                shmdt(ctrl);
-       if (shm)
-               free(shm);
+       free(shm);
        return result;
 }
 
index 2d509097db62d04f2e5cbb1a962a7a45366bbdc8..87ef91c9c691824a5d5aa8c18a01337e4018f3d3 100644 (file)
@@ -342,8 +342,7 @@ int snd_rawmidi_close(snd_rawmidi_t *rawmidi)
        int err;
        assert(rawmidi);
        err = rawmidi->ops->close(rawmidi);
-       if (rawmidi->name)
-               free(rawmidi->name);
+       free(rawmidi->name);
        if (rawmidi->dl_handle)
                snd_dlclose(rawmidi->dl_handle);
        free(rawmidi);
index b15dadb64ae8c205468dc8537b121c68be3e1c29..d33bbbe31802df945ddb30bdc47b503a221bff7f 100644 (file)
@@ -316,11 +316,10 @@ int snd_rawmidi_hw_open(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp,
 
  _nomem:
        close(fd);
-       if (hw)
-               free(hw);
-       if (inputp && *inputp)
+       free(hw);
+       if (inputp)
                free(*inputp);
-       if (outputp && *outputp)
+       if (outputp)
                free(*outputp);
        return -ENOMEM;
 }
index 51123e420cccc0d51ca33293c36a92bffe5861be..a06476aa3e625515a40074ccec160ac3665ec711 100644 (file)
@@ -385,11 +385,10 @@ int snd_rawmidi_virtual_open(snd_rawmidi_t **inputp, snd_rawmidi_t **outputp,
                snd_seq_close(seq_handle);
        if (virt->midi_event)
                snd_midi_event_free(virt->midi_event);
-       if (virt)
-               free(virt);
-       if (inputp && *inputp)
+       free(virt);
+       if (inputp)
                free(*inputp);
-       if (outputp && *outputp)
+       if (outputp)
                free(*outputp);
        return err;
 }
index 07954a35b3fafcc314d4adf7f83b2e66f74eec37..a2424c9a32ebef7fcf62e367b218bb61f7d7da29 100644 (file)
@@ -1029,14 +1029,10 @@ int snd_seq_close(snd_seq_t *seq)
        int err;
        assert(seq);
        err = seq->ops->close(seq);
-       if (seq->obuf)
-               free(seq->obuf);
-       if (seq->ibuf)
-               free(seq->ibuf);
-       if (seq->tmpbuf)
-               free(seq->tmpbuf);
-       if (seq->name)
-               free(seq->name);
+       free(seq->obuf);
+       free(seq->ibuf);
+       free(seq->tmpbuf);
+       free(seq->name);
        free(seq);
        return err;
 }
index b14954564ec56ff45a5b5672e31c1343ae1737f5..20ba808ac5497e190136c3940c44a2f54a04b115 100644 (file)
@@ -167,8 +167,7 @@ int snd_midi_event_new(size_t bufsize, snd_midi_event_t **rdev)
 void snd_midi_event_free(snd_midi_event_t *dev)
 {
        if (dev != NULL) {
-               if (dev->buf)
-                       free(dev->buf);
+               free(dev->buf);
                free(dev);
        }
 }
@@ -253,8 +252,7 @@ int snd_midi_event_resize_buffer(snd_midi_event_t *dev, size_t bufsize)
        dev->buf = new_buf;
        dev->bufsize = bufsize;
        reset_encode(dev);
-       if (old_buf)
-               free(old_buf);
+       free(old_buf);
        return 0;
 }
 
index 8b3da1f25b442a4d8669f70342e708f2b1932b43..fbb2624eb1ef008c1bbbbdd9867540cf9066b41b 100644 (file)
@@ -243,8 +243,7 @@ int snd_timer_close(snd_timer_t *timer)
                snd_async_del_handler(h);
        }
        err = timer->ops->close(timer);
-       if (timer->name)
-               free(timer->name);
+       free(timer->name);
        free(timer);
        return err;
 }
index 58c2d5a38381689f85c732b924069277afb4b0fa..bd88edb6746c97d6e8d81bdb140780c9a90fd27e 100644 (file)
@@ -197,8 +197,7 @@ int snd_timer_query_close(snd_timer_query_t *timer)
        int err;
        assert(timer);
        err = timer->ops->close(timer);
-       if (timer->name)
-               free(timer->name);
+       free(timer->name);
        free(timer);
        return err;
 }