author | ecalot
<ecalot> 2005-06-14 11:27:57 UTC |
committer | ecalot
<ecalot> 2005-06-14 11:27:57 UTC |
parent | 8877eb5844542b7e368e84b6996bc91b435ecb63 |
PR/src/include/memory.h | +10 | -7 |
PR/src/include/parse.h | +0 | -1 |
PR/src/include/search.h | +0 | -2 |
PR/src/lib/layers/memory.c | +12 | -107 |
PR/src/lib/xml/parse.c | +0 | -12 |
PR/src/lib/xml/search.c | +0 | -10 |
diff --git a/PR/src/include/memory.h b/PR/src/include/memory.h index 2211865..9d5ba41 100644 --- a/PR/src/include/memory.h +++ b/PR/src/include/memory.h @@ -34,20 +34,23 @@ memory.h: Princed Resources : Memory handling headers #ifndef _MEMORY_H_ #define _MEMORY_H_ -/* #define MEM_CHECK */ - #include <stdlib.h> + #define getMemory(size) ((unsigned char*)malloc(size)) char* strallocandcopy(const char* text); #define freeAllocation(m) if ((m)!=NULL) free(m) -#ifdef MEM_CHECK -void myfree(void* a,char* fileName,int line); -void* mymalloc(int size,char* fileName,int line); -void showStats(); +/* equalsIgnoreCase is coded unless we are in the BSD standars that is taken from string.h */ +#ifdef __USE_BSD +#include <string.h> +#define IGNORE_EQUALS +#define equalsIgnoreCase(a,b) (!strcasecmp(a,b)) #else -#define showInfo(a) +#define equalsIgnoreCase(a,b) equalsIgnoreCase2(a,b) +int equalsIgnoreCase2(const char s1[],const char s2[]); #endif +void str5uppercpy (char* dst,const char* src); + #endif diff --git a/PR/src/include/parse.h b/PR/src/include/parse.h index 3683cd8..1de78b5 100644 --- a/PR/src/include/parse.h +++ b/PR/src/include/parse.h @@ -34,7 +34,6 @@ xmlparse.h: Princed Resources : xml handling functions headers #ifndef _XMLPARSE_H_ #define _XMLPARSE_H_ -int equalsIgnoreCase(const char s1[],const char s2[]); const char* getExtDesc(int type); /* Constants */ diff --git a/PR/src/include/search.h b/PR/src/include/search.h index f003db4..b1aad4f 100644 --- a/PR/src/include/search.h +++ b/PR/src/include/search.h @@ -43,8 +43,6 @@ xmlparse.h: Princed Resources : xml handling functions header file #include "xmlparse.h" #include "reslist.h" -void str5uppercpy (char* dst,const char* src); - /****************************************************************\ | Tag Tree Searching Functions | \****************************************************************/ diff --git a/PR/src/lib/layers/memory.c b/PR/src/lib/layers/memory.c index 22b26d3..04d39b6 100644 --- a/PR/src/lib/layers/memory.c +++ b/PR/src/lib/layers/memory.c @@ -34,7 +34,6 @@ memory.c: Princed Resources : Memory handling #include "memory.h" #include <string.h> -#ifndef MEM_CHECK char* strallocandcopy(const char* text) { int size; char* aux; @@ -45,114 +44,20 @@ char* strallocandcopy(const char* text) { return aux; } -#else -#include <stdlib.h> -#include <stdio.h> - -typedef struct memm { - struct memm* next; - void* pointer; - char file[30]; - int line; - int size; -}memm; - -static memm* list=NULL; -static int memcounter=0; -static long int memsize=0; -static long int memsizef=0; - -void* mymalloc(int size,char* fileName,int line) { - memm* nodo; - void* p; - p=malloc(size); - nodo=malloc(sizeof(memm)); - nodo->next=list; - list=nodo; - strcpy(nodo->file,fileName); - nodo->line=line; - nodo->size=size; - nodo->pointer=p; - /*if (!(memcounter%100)) - //fprintf(stderr,"Memory allocation: %d bytes at %p in %d@%s (%d/%d)\n",size,p,line,fileName,memsize,memcounter); */ - memcounter++; - memsize+=size; - memsizef+=size; - return p; -} - -void myfree(void* a,char* fileName,int line) { - memm* currentNode; - memm* priorNode=NULL; - memcounter--; - /*if ((!(memcounter%100))||((memcounter<100)&&(memcounter>-100))) - //fprintf(stderr,"Liberando memoria? -> %p (%d/%d)\n",a,memsize,memcounter);*/ - - free(a); - - if (list==NULL) { - fprintf(stderr,"Error!!!! se pidio liberar %p pero no estaba alocado (lista vacia)\n",a); - return; /* Empty list */ - } - currentNode=list; - while ((currentNode->pointer!=a)&&(currentNode->next!=NULL)) { - priorNode=currentNode; - currentNode=currentNode->next; - } - if (currentNode->pointer!=a) { - fprintf(stderr,"Error!!!! se pidio liberar %p pero no estaba alocado %d@%s\n",a,line,fileName); - return; /* Not found */ - } - - memsizef-=currentNode->size; - - /*fprintf(stderr,"Liberada: %d bytes at %p alloc: %d@%s | free %d@%s (%d/%d)\n",currentNode->size,currentNode->pointer,currentNode->line,currentNode->file,line,fileName,memsize,memcounter);*/ - - /* free node and set prior pointer to the next */ - if (priorNode==NULL) { - list=currentNode->next; - } else { - priorNode->next=currentNode->next; +void str5uppercpy (char* dst,const char* src) { + int i; + for (i=0;(i<4)&&(*src);i++) { + *dst=((*src>='a')&&(*src<='z'))?*src&0xDF:*src; + src++; + dst++; } - free(currentNode); - -} - -void showInfo(void* a) { - memm* currentNode; - memm* priorNode=NULL; - - if (list==NULL) { - fprintf(stderr,"lista vacia\n"); - return; /* Empty list */ - } - currentNode=list; - while ((currentNode->pointer!=a)&&(currentNode->next!=NULL)) { - priorNode=currentNode; - currentNode=currentNode->next; - } - if (currentNode->pointer!=a) { - fprintf(stderr,"Puntero no alocado\n"); - return; /* Not found */ - } - - fprintf(stderr,"showInfo: %d bytes at %p alloc: %d@%s Mem tot: %d\n",currentNode->size,currentNode->pointer,currentNode->line,currentNode->file,memcounter); - + *dst=0; } -void showStats() { - fprintf(stderr,"Total de memoria manejada: %d. Allocaciones: %d. Memoria no liberada: %d\n",memsize,memcounter,memsizef); - - memm* currentNode; - if (list==NULL) { - fprintf(stderr,"Todo COOL!!!!!\n"); - return; /* Empty list */ - } - currentNode=list; - do { - fprintf(stderr,"en %s@%d alocaste %d en %p y no los liberaste\n",currentNode->file,currentNode->line,currentNode->size,currentNode->pointer); - currentNode=currentNode->next; - } while (currentNode->next!=NULL); - +#ifndef IGNORE_EQUALS +int equalsIgnoreCase2(const char s1[],const char s2[]) { + int i=0; + for (;((s1[i]&0xDF)==(s2[i]&0xDF))&&s1[i];i++); + return !(s1[i]||s2[i]); } #endif diff --git a/PR/src/lib/xml/parse.c b/PR/src/lib/xml/parse.c index 643f21d..a447f64 100644 --- a/PR/src/lib/xml/parse.c +++ b/PR/src/lib/xml/parse.c @@ -146,18 +146,6 @@ int attribFill(char* attr,char* val, tTag* t) { return PR_RESULT_ERR_XML_ATTR; } -/****************************************************************\ -| Other Modules Functions | -\****************************************************************/ - -/* Taken from parser.c */ - -int equalsIgnoreCase(const char s1[],const char s2[]) { - int i=0; - for (;((s1[i]&0xDF)==(s2[i]&0xDF))&&s1[i];i++); - return !(s1[i]||s2[i]); -} - /****************************************************************\ | XML Parsing Functions | \****************************************************************/ diff --git a/PR/src/lib/xml/search.c b/PR/src/lib/xml/search.c index 809545a..d387af9 100644 --- a/PR/src/lib/xml/search.c +++ b/PR/src/lib/xml/search.c @@ -44,16 +44,6 @@ search.c: Princed Resources : specific xml handling functions #include "memory.h" #include <string.h> -void str5uppercpy (char* dst,const char* src) { - int i; - for (i=0;(i<4)&&(*src);i++) { - *dst=((*src>='a')&&(*src<='z'))?*src&0xDF:*src; - src++; - dst++; - } - *dst=0; -} - /****************************************************************\ | Tag Tree Searching Functions | \****************************************************************/