]> git.alsa-project.org Git - alsa-utils.git/commitdiff
fixes for coping with zero elements or groups
authorAbramo Bagnara <abramo@alsa-project.org>
Mon, 13 Dec 1999 20:03:30 +0000 (20:03 +0000)
committerAbramo Bagnara <abramo@alsa-project.org>
Mon, 13 Dec 1999 20:03:30 +0000 (20:03 +0000)
gamix/main.c
gamix/probe.c
xamixer2/display.c

index 9d9362cff424e7eb712dc7b2a36c677b3fd2392a..d13a6054b8ef4110e929700a2933e5acbc6c2588 100644 (file)
@@ -5,7 +5,7 @@ GtkWidget *window;
 GtkWidget *main_vbox;
 GtkWidget *mixer_container;
 GtkWidget *exit_item;
-unsigned char *nomem_msg = N_("No enough ememory.\n");
+unsigned char *nomem_msg = N_("No enough memory.\n");
 
 int main(int , char **);
 int disp_mixer( void );
index aa26931a120f2cdfaf4584fd35ceddb481e973f0..86c72a9eaaa448cb04d07f461edbd2f33b36b17e 100644 (file)
@@ -83,7 +83,7 @@ gint probe_mixer( void ) {
                        }
                        groups.pgroups = (snd_mixer_gid_t *)g_malloc(groups.groups_over
                                                                                                        *sizeof(snd_mixer_eid_t));
-                       if( groups.pgroups == NULL ) {
+                       if( groups.pgroups == NULL && groups.groups_over) {
                                fprintf(stderr,nomem_msg);
                                snd_ctl_close(p_handle);
                                snd_mixer_close(m_handle);
@@ -107,7 +107,7 @@ gint probe_mixer( void ) {
                        }
                        es.pelements = (snd_mixer_eid_t *)g_malloc(
                                                                es.elements_over * sizeof(snd_mixer_eid_t));
-                       if( es.pelements == NULL ) {
+                       if( es.pelements == NULL && es.elements_over) {
                                fprintf(stderr,nomem_msg);
                                snd_ctl_close(p_handle);
                                snd_mixer_close(m_handle);
@@ -123,7 +123,7 @@ gint probe_mixer( void ) {
                                return -1;
                        }
                        es_nums = (int *)g_malloc(es.elements * sizeof(int));
-                       if( es_nums == NULL ) {
+                       if( es_nums == NULL && es.elements) {
                                fprintf(stderr,nomem_msg);
                                snd_ctl_close(p_handle);
                                snd_mixer_close(m_handle);
@@ -176,7 +176,7 @@ gint probe_mixer( void ) {
                                }
                                group->g.pelements = (snd_mixer_eid_t *)g_malloc(
                                                        group->g.elements_over*sizeof(snd_mixer_eid_t));
-                               if( group->g.pelements == NULL ) {
+                               if( group->g.pelements == NULL && group->g.elements_over) {
                                        snd_ctl_close(p_handle);
                                        fprintf(stderr,nomem_msg);
                                        snd_mixer_close(m_handle);
@@ -193,7 +193,7 @@ gint probe_mixer( void ) {
                                }
                                group->e=(s_element_t *)g_malloc(group->g.elements_size*
                                                                                           sizeof(s_element_t));
-                               if( group->e == NULL ) {
+                               if( group->e == NULL && group->g.elements_size) {
                                        fprintf(stderr,nomem_msg);
                                        snd_ctl_close(p_handle);
                                        snd_mixer_close(m_handle);
index a9940ae28157dbec013c294d0d09c791afe61428..afbee9e1c6c199dc0c058802259132e952a9e36c 100644 (file)
@@ -62,9 +62,11 @@ GtkWidget *create_mixer_page(int card_num, int mixer_num)
        w = (int)(1.5 * 
                  (float)card[i].mixer[j].info.elements / 
                  (float)card[i].mixer[j].info.groups);
-
-       /* Compute the number of groups in a column */
-       col = (card[i].mixer[j].info.groups + w - 1)/ w;
+       if (w == 0)
+               col = 0;
+       else
+               /* Compute the number of groups in a column */
+               col = (card[i].mixer[j].info.groups + w - 1)/ w;
 
        /* Create the main bounding box */
        hbox = gtk_hbox_new(FALSE, 0);