fixes for coping with zero elements or groups

This commit is contained in:
Abramo Bagnara 1999-12-13 20:03:30 +00:00
parent c1f35c1425
commit 0dcb344612
3 changed files with 11 additions and 9 deletions

View 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 );

View 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);

View file

@ -62,7 +62,9 @@ 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);
if (w == 0)
col = 0;
else
/* Compute the number of groups in a column */
col = (card[i].mixer[j].info.groups + w - 1)/ w;