From a892a5f5d8fc83ff626cc91837e311cc6581f6a66ad2102af82fb5a87df40021 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Rom=C3=A1n=20Archidona?= Date: Sat, 22 Sep 2018 12:40:43 +0200 Subject: [PATCH] Removed every cast to malloc() --- dlls/src/graphics/SDL_rotozoom.c | 8 ++++---- dlls/src/graphics/carga.c | 2 +- ediv/src/ediv/compiler.c | 16 ++++++++-------- ediv/src/ediv/config.c | 2 +- ediv/src/ediv/dll_load.c | 2 +- ediv/src/ediv/ediv.c | 2 +- ediv/src/ediv/encrypt.c | 8 ++++---- ediv/src/ediv/ltlex.c | 2 +- ediv/src/ediv/modulos.c | 6 +++--- ediv/src/ediv/varindex.c | 4 ++-- ediv/src/encrypt/encrypt.c | 8 ++++---- ediv/src/shared/dll_load.c | 2 +- ediv/src/stub/dll_load.c | 2 +- ediv/src/stub/ediv_export.c | 2 +- ediv/src/stub/inte.c | 2 +- ediv/src/stub/modulos.c | 6 +++--- ediv/src/stub/stub.c | 16 ++++++++-------- util/src/doku/doku.c | 10 +++++----- util/src/iconchanger/iconchanger.c | 4 ++-- 19 files changed, 52 insertions(+), 52 deletions(-) diff --git a/dlls/src/graphics/SDL_rotozoom.c b/dlls/src/graphics/SDL_rotozoom.c index 2aac820..1854e83 100644 --- a/dlls/src/graphics/SDL_rotozoom.c +++ b/dlls/src/graphics/SDL_rotozoom.c @@ -66,11 +66,11 @@ zoomSurfaceRGBA (SDL_Surface * src, SDL_Surface * dst, int smooth) } /* Allocate memory for row increments */ - if ((sax = (int *) malloc ((dst->w + 1) * sizeof (Uint32))) == NULL) + if ((sax = malloc ((dst->w + 1) * sizeof (Uint32))) == NULL) { return (-1); } - if ((say = (int *) malloc ((dst->h + 1) * sizeof (Uint32))) == NULL) + if ((say = malloc ((dst->h + 1) * sizeof (Uint32))) == NULL) { free (sax); return (-1); @@ -213,11 +213,11 @@ zoomSurfaceY (SDL_Surface * src, SDL_Surface * dst) sy = (Uint32) (65536.0 * (float) src->h / (float) dst->h); /* Allocate memory for row increments */ - if ((sax = (Uint32 *) malloc (dst->w * sizeof (Uint32))) == NULL) + if ((sax = malloc (dst->w * sizeof (Uint32))) == NULL) { return (-1); } - if ((say = (Uint32 *) malloc (dst->h * sizeof (Uint32))) == NULL) + if ((say = malloc (dst->h * sizeof (Uint32))) == NULL) { if (sax != NULL) { diff --git a/dlls/src/graphics/carga.c b/dlls/src/graphics/carga.c index a1b90bb..5af1943 100644 --- a/dlls/src/graphics/carga.c +++ b/dlls/src/graphics/carga.c @@ -136,7 +136,7 @@ int eDIV_LOAD_FPG(FUNCTION_PARAMS) fread(files[0].mapa[num].cpoint,2,2*infomapa.number_of_points,f) ; } - graphic = (char*)malloc(infomapa.wide*infomapa.height*bpp/8); + graphic = malloc(infomapa.wide*infomapa.height*bpp/8); fread(graphic,1,infomapa.wide*infomapa.height*bpp/8,f); files[0].mapa[num].Surface = SDL_CreateRGBSurfaceFrom(graphic,infomapa.wide,infomapa.height,bpp,infomapa.wide*bpp/8,0,0,0,0) ; diff --git a/ediv/src/ediv/compiler.c b/ediv/src/ediv/compiler.c index 742efca..9e909a2 100644 --- a/ediv/src/ediv/compiler.c +++ b/ediv/src/ediv/compiler.c @@ -83,7 +83,7 @@ void prepara_compilacion() /* Inicializamos el vector de nombres */ - vnom=(byte *) e_malloc(max_obj*long_med_id+1024); + vnom = e_malloc(max_obj*long_med_id+1024); ivnom.b=vnom; @@ -100,17 +100,17 @@ void prepara_compilacion() /* Buffer para el bytecode */ imem_max=default_buffer; imem=0; - mem_ory=mem=(int*)e_malloc(imem_max*sizeof(int)); + mem_ory = mem = e_malloc(imem_max*sizeof(int)); memset(mem,0,imem_max*sizeof(int)); /* Buffer para variables locales y privadas */ iloc_max=default_buffer/2; iloc=0; iloc_len=0; - loc=(int*)e_malloc(iloc_max*sizeof(int)); + loc = e_malloc(iloc_max*sizeof(int)); memset(loc,0,iloc_max*sizeof(int)); /* ¿Que es esto? */ ifrm_max=default_buffer/2; - frm=(int*)e_malloc(ifrm_max*sizeof(int)); + frm = e_malloc(ifrm_max*sizeof(int)); memset(frm,0,ifrm_max*sizeof(int)); imem=long_header; @@ -328,7 +328,7 @@ void compila() /* lo pasamos todo del temporal a la memoria */ l=ftell(fvar); fseek(fvar,0,SEEK_SET); - varptr=(byte*)e_malloc(l); + varptr = e_malloc(l); fread(varptr,1,l,fvar); fclose(fvar); #ifdef _DEBUG @@ -340,9 +340,9 @@ void compila() if ((f=fopen(outfilename,"ab"))!=NULL) { fwrite(nombre_program,strlen((const char*)nombre_program)+1,1,f); - p=(byte*)e_malloc((imem+iloc)*4); + p = e_malloc((imem+iloc)*4); m=(imem+iloc)*4+1024; - q=(byte*)e_malloc(m); + q = e_malloc(m); if (p!=NULL && q!=NULL) { fwrite(mem,4,9,f); /* mem[0..8] */ memcpy(p,&mem[9],(imem-9)*4); @@ -354,7 +354,7 @@ void compila() fwrite(q,1,m,f); free(q); free(p); m=l*2; - q=(byte*)e_malloc(m); + q = e_malloc(m); if(!compress(q,&m,varptr,l)) { /* nºvariables,longitud_datos_descomp,longitud_datos_comp,datos_comp... */ fwrite(&num_indexed_vars,1,4,f); fwrite(&l,1,4,f); diff --git a/ediv/src/ediv/config.c b/ediv/src/ediv/config.c index 39c60e8..864ea65 100644 --- a/ediv/src/ediv/config.c +++ b/ediv/src/ediv/config.c @@ -78,7 +78,7 @@ void lee_ediv_cfg(char* ediv_cfg) fseek(f,0,SEEK_END); tamano=ftell(f); fseek(f,0,SEEK_SET); - buffer=(char*)e_malloc(tamano); + buffer = e_malloc(tamano); fread(buffer,1,tamano,f); fclose(f); diff --git a/ediv/src/ediv/dll_load.c b/ediv/src/ediv/dll_load.c index 5caa292..3644d1a 100644 --- a/ediv/src/ediv/dll_load.c +++ b/ediv/src/ediv/dll_load.c @@ -125,7 +125,7 @@ static int AddDLLReference(void *pImageBase, char *svName, DWORD dwFlags) } // Add new dll to list - cur=(IMAGE_PARAMETERS *)e_malloc(sizeof(IMAGE_PARAMETERS)); + cur = e_malloc(sizeof(IMAGE_PARAMETERS)); if(cur==NULL) { LeaveCriticalSection(&g_DLLCrit); return -1; diff --git a/ediv/src/ediv/ediv.c b/ediv/src/ediv/ediv.c index 90c47d3..eb437cf 100644 --- a/ediv/src/ediv/ediv.c +++ b/ediv/src/ediv/ediv.c @@ -248,7 +248,7 @@ int main(int argc, char *argv[]) /* mete el PRG en el buffer prog */ fseek(fp,0,SEEK_END); progsize=ftell(fp); - prog = (unsigned char *)e_malloc(progsize+1); + prog = e_malloc(progsize+1); fseek(fp,0,SEEK_SET); p=(char*)prog; do { diff --git a/ediv/src/ediv/encrypt.c b/ediv/src/ediv/encrypt.c index 0a278c9..4a7f005 100644 --- a/ediv/src/ediv/encrypt.c +++ b/ediv/src/ediv/encrypt.c @@ -110,7 +110,7 @@ void _encriptar(int encode, char * fichero, char * clave) fseek(f,0,SEEK_END); size=ftell(f); - if ((ptr=(byte *)malloc(size))!=NULL) { + if ((ptr=malloc(size))!=NULL) { fseek(f,0,SEEK_SET); if(fread(ptr,1,size,f) ==(unsigned int) size) { fclose(f); @@ -181,7 +181,7 @@ void _comprimir(int encode, char *fichero) { fseek(f,0,SEEK_END); size=ftell(f); - if ((ptr=(byte *)malloc(size))!=NULL) { + if ((ptr=malloc(size))!=NULL) { fseek(f,0,SEEK_SET); if(fread(ptr,1,size,f) == size) { @@ -203,7 +203,7 @@ void _comprimir(int encode, char *fichero) { return; size2=size+size/100+256; - if ((ptr_dest=(byte *)malloc(size2))==NULL) { + if ((ptr_dest=malloc(size2))==NULL) { e_free(ptr); return; } @@ -226,7 +226,7 @@ void _comprimir(int encode, char *fichero) { size2=*(int*)(ptr+8); - if ((ptr_dest=(byte *)malloc(size2))==NULL) { + if ((ptr_dest=malloc(size2))==NULL) { e_free(ptr); return; } diff --git a/ediv/src/ediv/ltlex.c b/ediv/src/ediv/ltlex.c index cfdd781..1550911 100644 --- a/ediv/src/ediv/ltlex.c +++ b/ediv/src/ediv/ltlex.c @@ -61,7 +61,7 @@ void analiza_ltlex(void){ /* Lo lee */ fseek(def,0,SEEK_END); len=ftell(def); - _buf=buf=(byte *) e_malloc(len+1); + _buf=buf= e_malloc(len+1); fseek(def,0,SEEK_SET); len=fread(buf,1,len,def); diff --git a/ediv/src/ediv/modulos.c b/ediv/src/ediv/modulos.c index 43da9fa..8638589 100644 --- a/ediv/src/ediv/modulos.c +++ b/ediv/src/ediv/modulos.c @@ -144,7 +144,7 @@ void dll_func() if(!leedll()) { dlls[numdlls].prioridad=0; /* guarda el nombre de fichero en la tabla de DLLs */ - dlls[0].nombre=(char*)e_malloc(strlen(rawname)+1); + dlls[0].nombre=e_malloc(strlen(rawname)+1); strcpy(dlls[0].nombre,rawname); /* importa las funciones de la DLL */ @@ -168,7 +168,7 @@ void dll_func() strcat(dllkey,rawname); if(ini) if(iniparser_getint(ini,dllkey,0)<=P_NUNCA) carga=0; if(carga) if(!leedll()) { - dlls[numdlls].nombre=(char*)e_malloc(strlen(rawname)+1); + dlls[numdlls].nombre=e_malloc(strlen(rawname)+1); strcpy(dlls[numdlls].nombre,rawname); dlls[numdlls].usado=0; if(ini) dlls[numdlls].prioridad=iniparser_getint(ini,dllkey,dlls[numdlls].prioridad); @@ -218,7 +218,7 @@ void dll_func() if(carga) { if(!leedll()) { - dlls[numdlls].nombre=(char*)e_malloc(strlen(rawname)+1); + dlls[numdlls].nombre=e_malloc(strlen(rawname)+1); strcpy(dlls[numdlls].nombre,rawname); dlls[numdlls].usado=0; diff --git a/ediv/src/ediv/varindex.c b/ediv/src/ediv/varindex.c index 8165db8..60173d2 100644 --- a/ediv/src/ediv/varindex.c +++ b/ediv/src/ediv/varindex.c @@ -137,10 +137,10 @@ void indexa_variable(tipo_t tipo, char* nombre, int ptr) #endif if(varindex) { - varindex=(varindex_t*)realloc(varindex,sizeof(varindex_t)*(num_indexed_vars+1)); + varindex=realloc(varindex,sizeof(varindex_t)*(num_indexed_vars+1)); } else { - varindex=(varindex_t*)e_malloc(sizeof(varindex_t)*(num_indexed_vars+1)); + varindex=e_malloc(sizeof(varindex_t)*(num_indexed_vars+1)); } varindex[num_indexed_vars].hash=h; varindex[num_indexed_vars].tipo=tipo; diff --git a/ediv/src/encrypt/encrypt.c b/ediv/src/encrypt/encrypt.c index 68d92f0..e3b84ff 100644 --- a/ediv/src/encrypt/encrypt.c +++ b/ediv/src/encrypt/encrypt.c @@ -137,7 +137,7 @@ void _encriptar(int encode, char * fichero, char * clave) if ((f=fopen(fichero,"rb"))!=NULL) { fseek(f,0,SEEK_END); size=ftell(f); - if ((ptr=(byte *)malloc(size))!=NULL) { + if ((ptr=malloc(size))!=NULL) { fseek(f,0,SEEK_SET); if(fread(ptr,1,size,f) ==(unsigned int) size) { fclose(f); @@ -224,7 +224,7 @@ void _comprimir(int encode, char *fichero) if ((f=fopen(fichero,"rb"))!=NULL) { fseek(f,0,SEEK_END); size=ftell(f); - if ((ptr=(byte *)malloc(size))!=NULL) { + if ((ptr=malloc(size))!=NULL) { fseek(f,0,SEEK_SET); if(fread(ptr,1,size,f) == size) { fclose(f); @@ -245,7 +245,7 @@ void _comprimir(int encode, char *fichero) return; stub_size=(int)size; size2=size+size/100+256; - if ((ptr_dest=(byte *)malloc(size2))==NULL) { + if ((ptr_dest=malloc(size2))==NULL) { free(ptr); return; } @@ -268,7 +268,7 @@ void _comprimir(int encode, char *fichero) return; size2=*(int*)(ptr+8); stub_size=(int)size2; - if ((ptr_dest=(byte *)malloc(size2))==NULL) { + if ((ptr_dest=malloc(size2))==NULL) { free(ptr); return; } diff --git a/ediv/src/shared/dll_load.c b/ediv/src/shared/dll_load.c index 7f1aa3e..defa4c9 100644 --- a/ediv/src/shared/dll_load.c +++ b/ediv/src/shared/dll_load.c @@ -124,7 +124,7 @@ static int AddDLLReference(void *pImageBase, char *svName, DWORD dwFlags) } // Add new dll to list - cur=(IMAGE_PARAMETERS *)malloc(sizeof(IMAGE_PARAMETERS)); + cur=malloc(sizeof(IMAGE_PARAMETERS)); if(cur==NULL) { LeaveCriticalSection(&g_DLLCrit); return -1; diff --git a/ediv/src/stub/dll_load.c b/ediv/src/stub/dll_load.c index 7f1aa3e..defa4c9 100644 --- a/ediv/src/stub/dll_load.c +++ b/ediv/src/stub/dll_load.c @@ -124,7 +124,7 @@ static int AddDLLReference(void *pImageBase, char *svName, DWORD dwFlags) } // Add new dll to list - cur=(IMAGE_PARAMETERS *)malloc(sizeof(IMAGE_PARAMETERS)); + cur=malloc(sizeof(IMAGE_PARAMETERS)); if(cur==NULL) { LeaveCriticalSection(&g_DLLCrit); return -1; diff --git a/ediv/src/stub/ediv_export.c b/ediv/src/stub/ediv_export.c index f97d299..a8e1b06 100644 --- a/ediv/src/stub/ediv_export.c +++ b/ediv/src/stub/ediv_export.c @@ -150,7 +150,7 @@ int EDIV_Export(char* cadena, int nparam, void* hfuncion) /*#define actfunc dlls[numdlls-1].ext_funcs[dlls[numdlls-1].nfuncs] - actfunc.cadena=(char*)e_malloc(strlen(cadena)+1); + actfunc.cadena=e_malloc(strlen(cadena)+1); strcpy(actfunc.cadena,cadena); actfunc.nparam = nparam; actfunc.hfuncion = hfuncion;*/ diff --git a/ediv/src/stub/inte.c b/ediv/src/stub/inte.c index c4a03c1..422d56e 100644 --- a/ediv/src/stub/inte.c +++ b/ediv/src/stub/inte.c @@ -48,7 +48,7 @@ int ini_interprete() first_loaded = 1 ; pila_max = 1024 ; - if ((pila=(int*)malloc(4*pila_max))==NULL) + if ((pila=malloc(4*pila_max))==NULL) critical_error(4); // no se pudo reservar memoria para la pila sp = 0 ; //por si acaso diff --git a/ediv/src/stub/modulos.c b/ediv/src/stub/modulos.c index 19204d2..6ae234b 100644 --- a/ediv/src/stub/modulos.c +++ b/ediv/src/stub/modulos.c @@ -68,7 +68,7 @@ void dll_func() // ke original, no? XD // guarda el nombre de fichero en la tabla de DLLs printf("\nGuardando el nombre de la dll..."); - dlls[0].nombre=(char*)e_malloc(strlen(fichero_dll.name)+1); + dlls[0].nombre=e_malloc(strlen(fichero_dll.name)+1); strcpy(dlls[0].nombre,fichero_dll.name); printf("\nGuardado el nombre de la dll..."); @@ -86,7 +86,7 @@ void dll_func() // ke original, no? XD strcat(fichdll,fichero_dll.name); // dlls[numdlls].nfuncs=0; if(!leedll()) { - dlls[numdlls].nombre=(char*)e_malloc(strlen(fichero_dll.name)+1); + dlls[numdlls].nombre=e_malloc(strlen(fichero_dll.name)+1); strcpy(dlls[numdlls].nombre,fichero_dll.name); dlls[numdlls].usado=0; numdlls++; @@ -126,7 +126,7 @@ void dll_func() // ke original, no? XD strcat(fichdll,fichero_dll->d_name); // dlls[numdlls].nfuncs=0; if(!leedll()) { - dlls[numdlls].nombre=(char*)e_malloc(strlen(fichero_dll->d_name)+1); + dlls[numdlls].nombre=e_malloc(strlen(fichero_dll->d_name)+1); strcpy(dlls[numdlls].nombre,fichero_dll->d_name); dlls[numdlls].usado=0; numdlls++; diff --git a/ediv/src/stub/stub.c b/ediv/src/stub/stub.c index 80e12cb..2551e3b 100644 --- a/ediv/src/stub/stub.c +++ b/ediv/src/stub/stub.c @@ -155,7 +155,7 @@ int main(int argc, char* argv[]) } - if ((mem=(int*)malloc(4*imem_max+1032*5+16*1025+3))!=NULL){ + if ((mem=malloc(4*imem_max+1032*5+16*1025+3))!=NULL){ mem=(int*)((((int)mem+3)/4)*4); @@ -169,7 +169,7 @@ int main(int argc, char* argv[]) nullstring[3]=imem_max+1+258*3; mem[nullstring[3]-1]=0xDAD00402; memcpy(mem,mimem,40); - if ((ptr=(byte*)malloc(len))!=NULL) { + if ((ptr=malloc(len))!=NULL) { read(f,ptr,len); @@ -205,9 +205,9 @@ int main(int argc, char* argv[]) read(f,&num_indexed_vars,4); read(f,&len_descomp,4); read(f,&len,4); - ptr=(byte*)e_malloc(len); + ptr=e_malloc(len); read(f,ptr,len); - vartemp=(byte*)e_malloc(len_descomp); + vartemp=e_malloc(len_descomp); if(uncompress(vartemp,&len_descomp,ptr,len)) { free(ptr); free(vartemp); @@ -215,7 +215,7 @@ int main(int argc, char* argv[]) critical_error(1); // error leyendo el código del programa } - varindex=(varindex_t*)e_malloc(num_indexed_vars*sizeof(varindex_t)); + varindex=e_malloc(num_indexed_vars*sizeof(varindex_t)); ptr=vartemp; for(i=0;i