shithub: rgbds

Download patch

ref: 3e4350afa4a855b9c33f971cc5484a911b4ca987
parent: 0d07caba60b5d082a22cbbb4eb78cfefabb0ea64
author: Anthony J. Bentley <anthony@cathet.us>
date: Thu Sep 25 20:39:29 EDT 2014

Don't cast calls to malloc().

--- a/src/asm/fstack.c
+++ b/src/asm/fstack.c
@@ -66,8 +66,7 @@
 	while (*ppFileStack)
 		ppFileStack = &((*ppFileStack)->pNext);
 
-	if ((*ppFileStack =
-		(struct sContext *) malloc(sizeof(struct sContext))) != NULL) {
+	if ((*ppFileStack = malloc(sizeof(struct sContext))) != NULL) {
 		(*ppFileStack)->FlexHandle = CurrentFlexHandle;
 		(*ppFileStack)->pNext = NULL;
 		strcpy((char *) (*ppFileStack)->tzFileName,
--- a/src/asm/lexer.c
+++ b/src/asm/lexer.c
@@ -116,11 +116,9 @@
 {
 	YY_BUFFER_STATE pBuffer;
 
-	if ((pBuffer =
-		(YY_BUFFER_STATE) malloc(sizeof(struct yy_buffer_state))) !=
-	    NULL) {
+	if ((pBuffer = malloc(sizeof(struct yy_buffer_state))) != NULL) {
 		if ((pBuffer->pBufferRealStart =
-			(char *) malloc(size + 1 + SAFETYMARGIN)) != NULL) {
+		    malloc(size + 1 + SAFETYMARGIN)) != NULL) {
 			pBuffer->pBufferStart = pBuffer->pBufferRealStart + SAFETYMARGIN;
 			pBuffer->pBuffer = pBuffer->pBufferRealStart + SAFETYMARGIN;
 			memcpy(pBuffer->pBuffer, mem, size);
@@ -139,8 +137,7 @@
 {
 	YY_BUFFER_STATE pBuffer;
 
-	if ((pBuffer =
-		(YY_BUFFER_STATE) malloc(sizeof(struct yy_buffer_state))) != NULL) {
+	if ((pBuffer = malloc(sizeof(struct yy_buffer_state))) != NULL) {
 		ULONG size;
 
 		fseek(f, 0, SEEK_END);
@@ -148,7 +145,7 @@
 		fseek(f, 0, SEEK_SET);
 
 		if ((pBuffer->pBufferRealStart =
-			(char *) malloc(size + 2 + SAFETYMARGIN)) != NULL) {
+			malloc(size + 2 + SAFETYMARGIN)) != NULL) {
 			char *mem;
 			ULONG instring = 0;
 
@@ -344,9 +341,7 @@
 		while (*ppHash)
 			ppHash = &((*ppHash)->pNext);
 
-		if (((*ppHash) =
-			(struct sLexString *) malloc(sizeof(struct sLexString))) !=
-		    NULL) {
+		if (((*ppHash) = malloc(sizeof(struct sLexString))) != NULL) {
 			if (((*ppHash)->tzName =
 				(char *) strdup(lex->tzName)) != NULL) {
 				(*ppHash)->nNameLength = strlen(lex->tzName);
--- a/src/asm/main.c
+++ b/src/asm/main.c
@@ -173,9 +173,7 @@
 {
 	struct sOptionStackEntry *pOpt;
 
-	if ((pOpt =
-		(struct sOptionStackEntry *)
-		malloc(sizeof(struct sOptionStackEntry))) != NULL) {
+	if ((pOpt = malloc(sizeof(struct sOptionStackEntry))) != NULL) {
 		pOpt->Options = CurrentOptions;
 		pOpt->pNext = pOptionStack;
 		pOptionStack = pOpt;
--- a/src/asm/output.c
+++ b/src/asm/output.c
@@ -77,9 +77,7 @@
 {
 	struct SectionStackEntry *pSect;
 
-	if ((pSect =
-		(struct SectionStackEntry *)
-		malloc(sizeof(struct SectionStackEntry))) != NULL) {
+	if ((pSect = malloc(sizeof(struct SectionStackEntry))) != NULL) {
 		pSect->pSection = pCurrentSection;
 		pSect->pNext = pSectionStack;
 		pSectionStack = pSect;
@@ -343,9 +341,7 @@
 		ppPSym = &((*ppPSym)->pBucketNext);
 	}
 
-	if ((*ppPSym = pPSym =
-		(struct PatchSymbol *) malloc(sizeof(struct PatchSymbol))) !=
-	    NULL) {
+	if ((*ppPSym = pPSym = malloc(sizeof(struct PatchSymbol))) != NULL) {
 		pPSym->pNext = NULL;
 		pPSym->pBucketNext = NULL;
 		pPSym->pSymbol = pSym;
@@ -393,8 +389,7 @@
 {
 	struct Patch *pPatch;
 
-	if ((pPatch =
-		(struct Patch *) malloc(sizeof(struct Patch))) != NULL) {
+	if ((pPatch = malloc(sizeof(struct Patch))) != NULL) {
 		pPatch->pNext = pCurrentSection->pPatches;
 		pPatch->nRPNSize = 0;
 		pPatch->pRPN = NULL;
@@ -472,7 +467,7 @@
 			break;
 		}
 	}
-	if ((pPatch->pRPN = (UBYTE *) malloc(rpnptr)) != NULL) {
+	if ((pPatch->pRPN = malloc(rpnptr)) != NULL) {
 		memcpy(pPatch->pRPN, rpnexpr, rpnptr);
 		pPatch->nRPNSize = rpnptr;
 	}
@@ -633,11 +628,8 @@
 		pSect = pSect->pNext;
 	}
 
-	if ((*ppSect =
-		(pSect =
-		    (struct Section *) malloc(sizeof(struct Section)))) != NULL) {
-		if ((pSect->pzName =
-			(char *) malloc(strlen(pzName) + 1)) != NULL) {
+	if ((*ppSect = (pSect = malloc(sizeof(struct Section)))) != NULL) {
+		if ((pSect->pzName = malloc(strlen(pzName) + 1)) != NULL) {
 			strcpy(pSect->pzName, pzName);
 			pSect->nType = secttype;
 			pSect->nPC = 0;
@@ -647,8 +639,7 @@
 			pSect->pPatches = NULL;
 			pPatchSymbols = NULL;
 
-			if ((pSect->tData =
-				(UBYTE *) malloc(SECTIONCHUNK)) != NULL) {
+			if ((pSect->tData = malloc(SECTIONCHUNK)) != NULL) {
 				return (pSect);
 			} else
 				fatalerror("Not enough memory for section");
--- a/src/asm/symbol.c
+++ b/src/asm/symbol.c
@@ -94,8 +94,7 @@
 	while ((*ppsym) != NULL)
 		ppsym = &((*ppsym)->pNext);
 
-	if (((*ppsym) =
-		(struct sSymbol *) malloc(sizeof(struct sSymbol))) != NULL) {
+	if (((*ppsym) = malloc(sizeof(struct sSymbol))) != NULL) {
 		strcpy((*ppsym)->tzName, s);
 		(*ppsym)->nValue = 0;
 		(*ppsym)->nType = 0;
@@ -570,8 +569,7 @@
 		nsym = createsymbol(tzSym);
 
 	if (nsym) {
-		if ((nsym->pMacro =
-			(char *) malloc(strlen(tzValue) + 1)) != NULL)
+		if ((nsym->pMacro = malloc(strlen(tzValue) + 1)) != NULL)
 			strcpy(nsym->pMacro, tzValue);
 		else
 			fatalerror("No memory for stringequate");
--- a/src/asm/yaccprt1.y
+++ b/src/asm/yaccprt1.y
@@ -130,8 +130,7 @@
 	src=pCurrentBuffer->pBuffer;
 	ulNewMacroSize=len;
 
-	if( (tzNewMacro=(char *)malloc(ulNewMacroSize+1))!=NULL )
-	{
+	if ((tzNewMacro = malloc(ulNewMacroSize + 1)) != NULL) {
 		ULONG i;
 
 		tzNewMacro[ulNewMacroSize]=0;
@@ -140,8 +139,7 @@
 			if( (tzNewMacro[i]=src[i])=='\n' )
 				nLineNo+=1;
 		}
-	}
-	else
+	} else
 		fatalerror( "No mem for REPT block" );
 
 	yyskipbytes( ulNewMacroSize+4 );
--- a/src/link/assign.c
+++ b/src/link/assign.c
@@ -64,7 +64,6 @@
 					struct sFreeArea *pNewArea;
 
 					if ((pNewArea =
-						(struct sFreeArea *)
 						malloc(sizeof(struct sFreeArea)))
 					    != NULL) {
 						*pNewArea = *pArea;