[Fwd: How to avoid cc warnings?]
Posted in 1998
Este es un mensaje multipartes en formato MIME. --------------D0E565BC11B526572CBC2634 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit #include <stdio.h> #include <search.h> #include <tipos.h> #define NARBOLES 75 #define NNODOS 500 /* no se usa */ #define LONCLAVE 50 #define LONDATO 513 /* TIPO NODO : consta de dos punteros : uno a la clave y otro al dato */ struct nodo { char *clave, *dato; } ; struct nodo *arboles[NARBOLES] ; /* numero de ultima entrada utilizada en vector de arboles */ short uarbol = -1 ; struct nodo **secuencia ; short isec ; char *malloc(), *consultar( short, char * ); void twalk(const void *, void (*)(const void *, VISIT, int)); /*extern void twalk(const void *, void (*)(const void *, VISIT, int));*/ /********************************** COMPANODOS */ int companodos( n1, n2 ) struct nodo *n1, *n2 ; { return strcmp( n1->clave, n2->clave ) ; } /********************************** MUESTRA */ void muestra( nodo, orden, nivel ) struct nodo **nodo; VISIT orden; int nivel; { if ( orden == preorder || orden == leaf ) printf( " Puntero = %d, Clave = %s, Dato = %s\\n\\r", *nodo, (*nodo)->clave, (*nodo)->dato ) ; } /********************************** C_VERARBOLES */ c_verarboles() { short i ; puts("\\r"); for( i=0 ; i<=uarbol ; i++ ) { printf( "ARBOL %d : %d : %d \\n\\r", i, &arboles[i], arboles[i] ); puts("\\r"); twalk( (char *)arboles[i], muestra ); puts("\\r"); } puts(""); return(0); } /*********************** C_CREAARBOL */ c_creaarbol() { uarbol++ ; if ( uarbol+1 == NARBOLES ) printf("%s %d","AVISO: Alcanzando num. max. arboles",NARBOLES); arboles[ uarbol ] = NULL ; retint( uarbol ) ; return(1) ; } /*********************** C_INSNODO */ c_insnodo() { ENTERO_POPINT arbol ; char clave[LONCLAVE], dato[LONDATO]; struct nodo *p, *p2; /* Regcoger parametros */ popquote( dato, sizeof(dato) ); cortatira( dato ); popquote( clave, sizeof(clave) ); cortatira( clave ); popint( &arbol ) ; /* Reservar espacio de memoria para el nodo, la clave y el dato */ p = (struct nodo *)malloc( sizeof(struct nodo) ) ; p->clave = malloc( strlen(clave) + 1 ) ; strcpy( p->clave, clave ) ; p->dato = malloc( strlen(dato) + 1 ) ; strcpy( p->dato, dato ) ; /* insertar/actualizar arbol */ p2 = (struct nodo *) tsearch( (char *)p, &(char *)arboles[ arbol ], companodos ) ; if ( p == p2 ) printf(" Ya existe esa clave ! " ); return(0); } /*********************** C_BORRNODO */ c_borrnodo() { ENTERO_POPINT arbol ; char clave[LONCLAVE]; struct nodo n, **pn = NULL, *pn2 ; /* Regcoger parametros */ popquote( clave, sizeof(clave) ); cortatira( clave ); popint( &arbol ) ; n.clave = clave ; pn = (struct nodo **)tfind( (char *)&n, &(char *)arboles[arbol], companodos ) ; if ( pn != NULL ) { pn2 = *pn ; free( pn2->clave ); free( pn2->dato ); pn = (struct nodo **) tdelete( (char *)&n, &(char *)arboles[arbol], companodos ) ; free( pn2 ); } return(0); } /*********************** C_CONSNODO */ c_consnodo() { ENTERO_POPINT arbol ; char clave[LONCLAVE]; struct nodo nodo, **p = NULL ; /* Regcoger parametros */ popquote( clave, sizeof(clave) ); cortatira( clave ); popint( &arbol ) ; nodo.clave = clave ; p = (struct nodo **) tfind( (char *)&nodo, &(char *)arboles[arbol], companodos ) ; if ( p == NULL ) retquote(NULL) ; else retquote( (*p)->dato ) ; return(1); } /* ############################################################### RECORRIDO DEL ARBOL ############################################################### */ /********************************** RECORRE */ void recorre( nodo, orden, nivel ) struct nodo **nodo; VISIT orden; int nivel; { if ( orden == preorder || orden == leaf ) { isec++ ; secuencia[ isec ] = *nodo ; } return; } /*********************** C_ABREARBOL */ c_abrearbol() { ENTERO_POPINT arbol ; popint( &arbol ); secuencia = (struct nodo **)calloc( 20, sizeof( struct nodo * ) ) ; isec = -1 ; twalk( (char *)arboles[ arbol ], recorre ); retint( isec+1 ); return(1); } /*********************** C_LEENODO */ c_leenodo() { ENTERO_POPINT elemento ; popint( &elemento ) ; elemento --; if ( elemento <= isec ) { retquote( secuencia[ elemento ]->clave ) ; retquote( secuencia[ elemento ]->dato ) ; } else { retquote( NULL ); retquote( NULL ); } return(2); } /*********************** C_CIERRAARBOL */ c_cierraarbol() { free( (char *)secuencia ) ; return(0); } -- Evelio Mart'nez Office: +34 96 374-47-02 +34 96 374-47-03 programacionaf@sinix.net Home: evelio.ml@ctv.es --------------D0E565BC11B526572CBC2634 Content-Type: message/rfc822 Content-Transfer-Encoding: 8bit Content-Disposition: inline Message-ID: <35F7E950.8ADFD3F1@sinix.net> Date: Thu, 10 Sep 1998 16:59:28 +0200 From: "Evelio Mart'nez" <programacionaf@sinix.net> Organization: AF INFORMATICA APLICADA, S.A. X-Mailer: Mozilla 4.03 [es] (Win95; I) MIME-Version: 1.0 Newsgroups: comp.unix.sco.programmer,comp.databases.informix Subject: How to avoid cc warnings? Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Hello again. Working under SCO UNIX Development System Release 5.0.0a 16Mar95. Sorry to bother you. This routines are included in the informix fglgo runtime. They were made 4 or 5 years ago in a Xenix development environment by a office mate that does not work here now. It seems he did not have any problem compiling. Now we are having problems (memory fault: core dumped) in our informix application because it has grown and we use a lot of configuration fields that use the binary trees. Finally I figured out that the problem was the reach of the number of trees limit. I have just changed the NARBOLES (number of trees) from 50 to 100, recompile and hope this to work. But it is not the case. Murphy is playing around here. My level of C knowledge is low, as you can suppose. I am sending you all the code and the warnings compiling with this script: cc $1.c -lc -o $1 "arboles.c", line 48: warning: argument is incompatible with prototype: arg #2 "arboles.c", line 87: warning: a cast does not yield an lvalue "arboles.c", line 87: warning: argument is incompatible with prototype: arg #2 "arboles.c", line 87: warning: argument is incompatible with prototype: arg #3 "arboles.c", line 107: warning: a cast does not yield an lvalue "arboles.c", line 107: warning: argume