MCPcopy Create free account
hub / github.com/Kitware/CMake / new_field

Function new_field

Source/CursesDialog/form/fld_def.c:256–308  ·  view source on GitHub ↗

--------------------------------------------------------------------------- | Facility : libnform | Function : FIELD *new_field( int rows, int cols, | int frow, int fcol, | int nrow, int nbuf ) | | Description : Create a new field with this many 'rows' and 'cols', | starting at '

Source from the content-addressed store, hash-verified

254|
255| Return Values : Pointer to the new field or NULL if failure.
256+--------------------------------------------------------------------------*/
257FIELD *new_field(int rows, int cols, int frow, int fcol, int nrow, int nbuf)
258{
259 FIELD *New_Field = (FIELD *)0;
260 int err = E_BAD_ARGUMENT;
261
262 if (rows>0 &&
263 cols>0 &&
264 frow>=0 &&
265 fcol>=0 &&
266 nrow>=0 &&
267 nbuf>=0 &&
268 ((err = E_SYSTEM_ERROR) != 0) && /* trick: this resets the default error */
269 (New_Field=(FIELD *)malloc(sizeof(FIELD))) )
270 {
271 *New_Field = default_field;
272 New_Field->rows = rows;
273 New_Field->cols = cols;
274 New_Field->drows = rows + nrow;
275 New_Field->dcols = cols;
276 New_Field->frow = frow;
277 New_Field->fcol = fcol;
278 New_Field->nrow = nrow;
279 New_Field->nbuf = nbuf;
280 New_Field->link = New_Field;
281
282 if (_nc_Copy_Type(New_Field,&default_field))
283 {
284 size_t len;
285
286 len = Total_Buffer_Size(New_Field);
287 if ((New_Field->buf = (char *)malloc(len)))
288 {
289 /* Prefill buffers with blanks and insert terminating zeroes
290 between buffers */
291 int i;
292
293 memset(New_Field->buf,' ',len);
294 for(i=0;i<=New_Field->nbuf;i++)
295 {
296 New_Field->buf[(New_Field->drows*New_Field->cols+1)*(i+1)-1]
297 = '\0';
298 }
299 return New_Field;
300 }
301 }
302 }
303
304 if (New_Field)
305 free_field(New_Field);
306
307 SET_ERROR( err );
308 return (FIELD *)0;
309}
310
311/*---------------------------------------------------------------------------

Callers 2

cmCursesWidgetMethod · 0.85
RenderMethod · 0.85

Calls 2

_nc_Copy_TypeFunction · 0.85
free_fieldFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…