diff --git a/demos/tuidemo.c b/demos/tuidemo.c index 134f5e99..391e9b5e 100644 --- a/demos/tuidemo.c +++ b/demos/tuidemo.c @@ -1,6 +1,6 @@ /********************************* tuidemo.c ********************************/ /* - * $Id: tuidemo.c,v 1.16 2006/07/29 06:00:54 wmcbrine Exp $ + * $Id: tuidemo.c,v 1.17 2006/08/12 21:13:45 wmcbrine Exp $ * * Author : P.J. Kunst (kunst@prl.philips.nl) * Date : 25-02-93 @@ -39,7 +39,7 @@ void address(void) int i, field = 50; for (i = 0; i < 5; i++) - fieldbuf[i] = (char *) calloc(1, field + 1); + fieldbuf[i] = calloc(1, field + 1); if (getstrings(fieldname, fieldbuf, field) != KEY_ESC) { diff --git a/dos/pdcclip.c b/dos/pdcclip.c index 8b7b2e4c..83e18509 100644 --- a/dos/pdcclip.c +++ b/dos/pdcclip.c @@ -20,7 +20,7 @@ #include #include -RCSID("$Id: pdcclip.c,v 1.23 2006/07/29 06:00:54 wmcbrine Exp $"); +RCSID("$Id: pdcclip.c,v 1.24 2006/08/12 21:13:45 wmcbrine Exp $"); /* global clipboard contents, should be NULL if none set */ @@ -62,7 +62,7 @@ int PDC_getclipboard(char **contents, long *length) return PDC_CLIP_EMPTY; len = strlen(pdc_DOS_clipboard); - if ((*contents = (char *)malloc(len + 1)) == NULL) + if ((*contents = malloc(len + 1)) == NULL) return PDC_CLIP_MEMORY_ERROR; strcpy(*contents, pdc_DOS_clipboard); @@ -105,7 +105,7 @@ int PDC_setclipboard(const char *contents, long length) if (contents != NULL) { - if ((pdc_DOS_clipboard = (char *)malloc(length + 1)) == NULL) + if ((pdc_DOS_clipboard = malloc(length + 1)) == NULL) return PDC_CLIP_MEMORY_ERROR; strcpy(pdc_DOS_clipboard, contents); diff --git a/dos/pdcscrn.c b/dos/pdcscrn.c index a0644ab7..a78be4da 100644 --- a/dos/pdcscrn.c +++ b/dos/pdcscrn.c @@ -24,7 +24,7 @@ # include #endif -RCSID("$Id: pdcscrn.c,v 1.46 2006/08/12 20:11:36 wmcbrine Exp $"); +RCSID("$Id: pdcscrn.c,v 1.47 2006/08/12 21:13:45 wmcbrine Exp $"); union REGS regs; /* used in various other modules */ @@ -141,11 +141,13 @@ int PDC_scr_open(int argc, char **argv) #endif PDC_LOG(("PDC_scr_open() - called\n")); - if (!(SP = (SCREEN *)calloc(1, sizeof(SCREEN))) - || !(atrtab = (unsigned char *)calloc(MAX_ATRTAB, 1)) ) + SP = calloc(1, sizeof(SCREEN)); + atrtab = calloc(MAX_ATRTAB, 1); + + if (!SP || !atrtab) return ERR; - SP->orig_attr = FALSE; + SP->orig_attr = FALSE; PDC_get_cursor_pos(&SP->cursrow, &SP->curscol); @@ -155,8 +157,8 @@ int PDC_scr_open(int argc, char **argv) pdc_adapter = PDC_query_adapter_type(); pdc_scrnmode = PDC_get_scrn_mode(); - pdc_font = PDC_get_font(); + SP->lines = PDC_get_rows(); SP->cols = PDC_get_columns(); @@ -177,8 +179,9 @@ int PDC_scr_open(int argc, char **argv) saved_lines = SP->lines; saved_cols = SP->cols; - if ((saved_screen = (unsigned short *)malloc(saved_lines - * saved_cols * 2)) == NULL) + saved_screen = malloc(saved_lines * saved_cols * 2); + + if (!saved_screen) { SP->_preserve = FALSE; return OK; diff --git a/os2/pdcclip.c b/os2/pdcclip.c index a949d541..24b75f21 100644 --- a/os2/pdcclip.c +++ b/os2/pdcclip.c @@ -24,7 +24,7 @@ #include #include -RCSID("$Id: pdcclip.c,v 1.20 2006/03/29 20:06:40 wmcbrine Exp $"); +RCSID("$Id: pdcclip.c,v 1.21 2006/08/12 21:13:45 wmcbrine Exp $"); /*man-start************************************************************** @@ -86,7 +86,7 @@ int PDC_getclipboard(char **contents, long *length) if (ulRet) { len = strlen((char *)ulRet); - *contents = (char *)malloc(len + 1); + *contents = malloc(len + 1); if (!*contents) rc = PDC_CLIP_MEMORY_ERROR; diff --git a/os2/pdcscrn.c b/os2/pdcscrn.c index ac6f41d9..e45f0b33 100644 --- a/os2/pdcscrn.c +++ b/os2/pdcscrn.c @@ -20,7 +20,7 @@ #include #include -RCSID("$Id: pdcscrn.c,v 1.41 2006/08/12 20:11:36 wmcbrine Exp $"); +RCSID("$Id: pdcscrn.c,v 1.42 2006/08/12 21:13:45 wmcbrine Exp $"); #ifdef EMXVIDEO static unsigned char *saved_screen = NULL; @@ -167,8 +167,10 @@ int PDC_scr_open(int argc, char **argv) #endif PDC_LOG(("PDC_scr_open() - called\n")); - if (!(SP = (SCREEN *)calloc(1, sizeof(SCREEN))) - || !(atrtab = (unsigned char *)calloc(MAX_ATRTAB, 1)) ) + SP = calloc(1, sizeof(SCREEN)); + atrtab = calloc(MAX_ATRTAB, 1); + + if (!SP || !atrtab) return ERR; #ifdef EMXVIDEO @@ -211,23 +213,17 @@ int PDC_scr_open(int argc, char **argv) { saved_lines = SP->lines; saved_cols = SP->cols; -#ifdef EMXVIDEO - if ((saved_screen = (unsigned char *)malloc(2 * saved_lines * - saved_cols)) == NULL) + + saved_screen = malloc(2 * saved_lines * saved_cols); + + if (!saved_screen) { SP->_preserve = FALSE; return OK; } - +#ifdef EMXVIDEO v_getline(saved_screen, 0, 0, saved_lines * saved_cols); #else - if ((saved_screen = (PCH)malloc(2 * saved_lines * - saved_cols)) == NULL) - { - SP->_preserve = FALSE; - return OK; - } - totchars = saved_lines * saved_cols * 2; VioReadCellStr((PCH)saved_screen, &totchars, 0, 0, (HVIO)NULL); #endif diff --git a/panel/panel.c b/panel/panel.c index 7bf5d311..44f47f37 100644 --- a/panel/panel.c +++ b/panel/panel.c @@ -23,7 +23,7 @@ #include #include -RCSID("$Id: panel.c,v 1.22 2006/08/10 01:44:08 wmcbrine Exp $"); +RCSID("$Id: panel.c,v 1.23 2006/08/12 21:13:45 wmcbrine Exp $"); /*man-start************************************************************** @@ -261,8 +261,7 @@ static void __calculate_obscure(void) { if (__panels_overlapped(pan, pan2)) { - if ((tobs = (PANELOBS *)malloc(sizeof(PANELOBS))) - == NULL) + if ((tobs = malloc(sizeof(PANELOBS))) == NULL) return; tobs->pan = pan2; @@ -588,7 +587,7 @@ int move_panel(PANEL *pan, int starty, int startx) PANEL *new_panel(WINDOW *win) { - PANEL *pan = (PANEL *)malloc(sizeof(PANEL)); + PANEL *pan = malloc(sizeof(PANEL)); if (!__stdscr_pseudo_panel.win) { diff --git a/win32/pdcscrn.c b/win32/pdcscrn.c index 49bf1ffc..2774b02b 100644 --- a/win32/pdcscrn.c +++ b/win32/pdcscrn.c @@ -24,7 +24,7 @@ #define CURSES_LIBRARY 1 #include -RCSID("$Id: pdcscrn.c,v 1.54 2006/08/12 20:11:36 wmcbrine Exp $"); +RCSID("$Id: pdcscrn.c,v 1.55 2006/08/12 21:13:45 wmcbrine Exp $"); #define PDC_RESTORE_NONE 0 #define PDC_RESTORE_BUFFER 1 @@ -139,8 +139,10 @@ int PDC_scr_open(int argc, char **argv) PDC_LOG(("PDC_scr_open() - called\n")); - if (!(SP = (SCREEN *)calloc(1, sizeof(SCREEN))) - || !(atrtab = (unsigned char *)calloc(MAX_ATRTAB, 1)) ) + SP = calloc(1, sizeof(SCREEN)); + atrtab = calloc(MAX_ATRTAB, 1); + + if (!SP || !atrtab) return ERR; hConOut = GetStdHandle(STD_OUTPUT_HANDLE); @@ -183,8 +185,10 @@ int PDC_scr_open(int argc, char **argv) { /* Attempt to save the complete console buffer */ - if ((ciSaveBuffer = (CHAR_INFO*)malloc(orig_scr.dwSize.X * - orig_scr.dwSize.Y * sizeof(CHAR_INFO))) == NULL) + ciSaveBuffer = malloc(orig_scr.dwSize.X * + orig_scr.dwSize.Y * sizeof(CHAR_INFO)); + + if (!ciSaveBuffer) { PDC_LOG(("PDC_scr_open() - malloc failure (1)\n")); @@ -214,8 +218,10 @@ int PDC_scr_open(int argc, char **argv) bufsize.Y = orig_scr.srWindow.Bottom - orig_scr.srWindow.Top + 1; - if ((ciSaveBuffer = (CHAR_INFO*)malloc(bufsize.X * - bufsize.Y * sizeof(CHAR_INFO))) == NULL) + ciSaveBuffer = malloc(bufsize.X * bufsize.Y * + sizeof(CHAR_INFO)); + + if (!ciSaveBuffer) { PDC_LOG(("PDC_scr_open() - malloc failure (2)\n")); diff --git a/x11/pdcclip.c b/x11/pdcclip.c index 3e206780..961af7cc 100644 --- a/x11/pdcclip.c +++ b/x11/pdcclip.c @@ -19,7 +19,7 @@ #include -RCSID("$Id: pdcclip.c,v 1.22 2006/07/31 00:20:18 wmcbrine Exp $"); +RCSID("$Id: pdcclip.c,v 1.23 2006/08/12 21:13:45 wmcbrine Exp $"); /*man-start************************************************************** @@ -69,7 +69,7 @@ int PDC_getclipboard(char **contents, long *length) if (len != 0) { - *contents = (char *)malloc(len + 1); + *contents = malloc(len + 1); if (!*contents) XCursesExitCursesProcess(6, "exiting from " diff --git a/x11/x11.c b/x11/x11.c index 8bc0d50c..eff47a65 100644 --- a/x11/x11.c +++ b/x11/x11.c @@ -32,7 +32,7 @@ #include #include -RCSID("$Id: x11.c,v 1.7 2006/07/31 00:20:18 wmcbrine Exp $"); +RCSID("$Id: x11.c,v 1.8 2006/08/12 21:13:45 wmcbrine Exp $"); #ifndef XPOINTER_TYPEDEFED typedef char * XPointer; @@ -2242,10 +2242,9 @@ static void SelectionSet(void) if (length > (int)tmpsel_length) { if (tmpsel_length == 0) - tmpsel = (chtype *)malloc(newlen * sizeof(chtype)); + tmpsel = malloc(newlen * sizeof(chtype)); else - tmpsel = (chtype *)realloc(tmpsel, - newlen * sizeof(chtype)); + tmpsel = realloc(tmpsel, newlen * sizeof(chtype)); } if (!tmpsel) @@ -3225,11 +3224,9 @@ static void XCursesProcessRequestsFromCurses(XtPointer client_data, int *fid, if (length > (long)tmpsel_length) { if (tmpsel_length == 0) - tmpsel = (chtype *)malloc((length + 1) * - sizeof(chtype)); + tmpsel = malloc((length + 1) * sizeof(chtype)); else - tmpsel = (chtype *)realloc(tmpsel, (length + 1) * - sizeof(chtype)); + tmpsel = realloc(tmpsel, (length + 1) * sizeof(chtype)); } if (!tmpsel)