X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=form%2Ffrm_def.c;h=e6897514ffddfe9cd24e9ed37f4668764d0c67e3;hp=c0a7855430e679658a8642e3a0d31daeb955c34b;hb=da1f84b7eb32f17e91f6de242132ab3b2d462148;hpb=5242fccf157e715ed878455a3efea6c82b840eb5 diff --git a/form/frm_def.c b/form/frm_def.c index c0a78554..e6897514 100644 --- a/form/frm_def.c +++ b/form/frm_def.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2006,2007 Free Software Foundation, Inc. * + * Copyright (c) 1998-2007,2008 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -32,7 +32,7 @@ #include "form.priv.h" -MODULE_ID("$Id: frm_def.c,v 1.21 2007/02/03 23:37:46 tom Exp $") +MODULE_ID("$Id: frm_def.c,v 1.23 2008/08/04 00:07:55 tom Exp $") /* this can't be readonly */ static FORM default_form = @@ -186,7 +186,7 @@ Connect_Fields(FORM *form, FIELD **fields) RETURN(E_BAD_ARGUMENT); /* allocate page structures */ - if ((pg = (_PAGE *) malloc(page_nr * sizeof(_PAGE))) != (_PAGE *) 0) + if ((pg = typeMalloc(_PAGE, page_nr)) != (_PAGE *) 0) { T((T_CREATE("_PAGE %p"), pg)); form->page = pg; @@ -234,8 +234,16 @@ Connect_Fields(FORM *form, FIELD **fields) fields[j]->page = page_nr; fld = Insert_Field_By_Position(fields[j], fld); } - form->page[page_nr].smin = fld->index; - form->page[page_nr].smax = fld->sprev->index; + if (fld) + { + form->page[page_nr].smin = fld->index; + form->page[page_nr].smax = fld->sprev->index; + } + else + { + form->page[page_nr].smin = 0; + form->page[page_nr].smax = 0; + } } RETURN(E_OK); } @@ -291,7 +299,7 @@ new_form(FIELD **fields) { int err = E_SYSTEM_ERROR; - FORM *form = (FORM *)malloc(sizeof(FORM)); + FORM *form = typeMalloc(FORM, 1); T((T_CALLED("new_form(%p)"), fields)); if (form)