Removed every cast to malloc()
This commit is contained in:
parent
335422f077
commit
a892a5f5d8
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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) ;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;*/
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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++;
|
||||
|
|
|
@ -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<num_indexed_vars;i++) {
|
||||
|
@ -244,9 +244,9 @@ int main(int argc, char* argv[])
|
|||
lseek(f,start_lin,SEEK_SET);
|
||||
read(f,&descomp_size,4);
|
||||
read(f,&comp_size,4);
|
||||
progcomp=(char*)e_malloc(comp_size);
|
||||
progcomp=e_malloc(comp_size);
|
||||
read(f,progcomp,comp_size);
|
||||
prog=(char*)e_malloc(descomp_size);
|
||||
prog=e_malloc(descomp_size);
|
||||
if(uncompress(prog,&descomp_size,progcomp,comp_size)) {
|
||||
close(f);
|
||||
free(prog);
|
||||
|
@ -255,7 +255,7 @@ int main(int argc, char* argv[])
|
|||
}
|
||||
free(progcomp);
|
||||
read(f,&linsize,4);
|
||||
lin=(int*)e_malloc(linsize*4*4+4);
|
||||
lin=e_malloc(linsize*4*4+4);
|
||||
lin[0]=linsize;
|
||||
|
||||
for(i=0;i<linsize;i++) {
|
||||
|
|
|
@ -88,7 +88,7 @@ int main(int argc, char* argv[])
|
|||
fseek(f,0,SEEK_END);
|
||||
tamano=ftell(f);
|
||||
fseek(f,0,SEEK_SET);
|
||||
if((buffer=(char*)malloc(tamano))==NULL) {
|
||||
if((buffer=malloc(tamano))==NULL) {
|
||||
printf("Error: memoria insuficiente\n");
|
||||
exit(3);
|
||||
}
|
||||
|
@ -140,7 +140,7 @@ int main(int argc, char* argv[])
|
|||
tamano=ftell(f);
|
||||
fseek(f,0,SEEK_SET);
|
||||
|
||||
if((buffer=(char*)malloc(tamano+1))==NULL) {
|
||||
if((buffer=malloc(tamano+1))==NULL) {
|
||||
printf("Error: memoria insuficiente\n");
|
||||
exit(5);
|
||||
}
|
||||
|
@ -253,7 +253,7 @@ void situame(char* actual, char* ant, char* sig, char* sup)
|
|||
tam=ftell(fi);
|
||||
fseek(fi,0,SEEK_SET);
|
||||
|
||||
if((buf=(char*)malloc(tam+1))==NULL) {
|
||||
if((buf=malloc(tam+1))==NULL) {
|
||||
printf("Error: memoria insuficiente\n");
|
||||
exit(14);
|
||||
}
|
||||
|
@ -363,7 +363,7 @@ void lee_titulo(char* fixero1, char* titulo)
|
|||
tam=ftell(fi);
|
||||
fseek(fi,0,SEEK_SET);
|
||||
|
||||
if((buf=(char*)malloc(tam+1))==NULL) {
|
||||
if((buf=malloc(tam+1))==NULL) {
|
||||
printf("Error: memoria insuficiente\n");
|
||||
exit(11);
|
||||
}
|
||||
|
@ -477,7 +477,7 @@ void procesa_subindice(char* actual)
|
|||
tam=ftell(fi);
|
||||
fseek(fi,0,SEEK_SET);
|
||||
|
||||
if((buf=(char*)malloc(tam+1))==NULL) {
|
||||
if((buf=malloc(tam+1))==NULL) {
|
||||
printf("Error: memoria insuficiente\n");
|
||||
exit(20);
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ int main(int argc, char* argv[])
|
|||
exit(4);
|
||||
}
|
||||
|
||||
ico=(unsigned char*)e_malloc(tamanyo);
|
||||
ico=e_malloc(tamanyo);
|
||||
fseek(f,0,SEEK_SET);
|
||||
fread(ico,tamanyo,1,f);
|
||||
fclose(f);
|
||||
|
@ -92,7 +92,7 @@ int main(int argc, char* argv[])
|
|||
fseek(f,0,SEEK_END);
|
||||
tamanyo=ftell(f);
|
||||
fseek(f,0,SEEK_SET);
|
||||
exe=(unsigned char*)e_malloc(tamanyo); /* no creo ke pase nada por unos 125 kb...
|
||||
exe=e_malloc(tamanyo); /* no creo ke pase nada por unos 125 kb...
|
||||
eso si, cuando se puedan meter el PAK y
|
||||
las DLL's en el exe, va a haber ke cambiar
|
||||
esto... */
|
||||
|
|
Loading…
Reference in a new issue