From 0dcb344612b3b64ad180c47835fa43251c483093 Mon Sep 17 00:00:00 2001 From: Abramo Bagnara Date: Mon, 13 Dec 1999 20:03:30 +0000 Subject: [PATCH] fixes for coping with zero elements or groups --- gamix/main.c | 2 +- gamix/probe.c | 10 +++++----- xamixer2/display.c | 8 +++++--- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/gamix/main.c b/gamix/main.c index 9d9362c..d13a605 100644 --- a/gamix/main.c +++ b/gamix/main.c @@ -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 ); diff --git a/gamix/probe.c b/gamix/probe.c index aa26931..86c72a9 100644 --- a/gamix/probe.c +++ b/gamix/probe.c @@ -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); diff --git a/xamixer2/display.c b/xamixer2/display.c index a9940ae..afbee9e 100644 --- a/xamixer2/display.c +++ b/xamixer2/display.c @@ -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); -- 2.47.1