[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: lynx-dev dev.10 progress
From: |
Leonid Pauzner |
Subject: |
Re: lynx-dev dev.10 progress |
Date: |
Mon, 18 Nov 2002 23:50:03 +0300 (MSK) |
One more patch from my code base (light optimization) -
calculate WWW_SOURCE once, it is now a constant, not a define;
use malloc instead of calloc in several places, particularly in HTList
operations (each field initialized explicitely).
diff -u -p -r -w LYNX2-8-.59F/src/lymainlo.c LYNX2-8-/src/lymainlo.c
--- LYNX2-8-.59F/src/lymainlo.c Mon Nov 18 19:51:46 2002
+++ LYNX2-8-/src/lymainlo.c Mon Nov 18 22:34:56 2002
@@ -158,7 +158,9 @@ PRIVATE int str_n_cmp(const char *p, con
#include <LYexit.h>
#include <LYLeaks.h>
+/* two constants: */
PUBLIC HTLinkType * LINK_INTERNAL = 0;
+PUBLIC HTAtom * WWW_SOURCE = 0;
#ifndef DONT_TRACK_INTERNAL_LINKS
#define NO_INTERNAL_OR_DIFFERENT(c,n) TRUE
@@ -5239,7 +5241,9 @@ int mainloop NOARGS
* It includes a space so it cannot conflict with any (valid) "TYPE"
* attributes on A elements. [According to which DTD, anyway??] - kw
*/
- LINK_INTERNAL = HTAtom_for("internal link"); /* init */
+ LINK_INTERNAL = HTAtom_for("internal link"); /* init, used as const */
+
+ WWW_SOURCE = HTAtom_for("www/source"); /* init, used as const */
/*
* curdoc.address contains the name of the file that is currently open.
diff -u -p -r -w LYNX2-8-.59F/www/library/implemen/htformat.h
LYNX2-8-/www/library/implemen/htformat.h
--- LYNX2-8-.59F/www/library/implemen/htformat.h Sun Jun 3 12:58:00 2001
+++ LYNX2-8-/www/library/implemen/htformat.h Sat Nov 16 23:11:50 2002
@@ -38,7 +38,8 @@ typedef HTAtom * HTFormat;
*/
/* Internal ones */
-#define WWW_SOURCE HTAtom_for("www/source") /* Whatever it was originally*/
+/* #define WWW_SOURCE HTAtom_for("www/source") */ /* Whatever it was
originally*/
+extern HTAtom * WWW_SOURCE; /* calculated once, heavy used */
/*
diff -u -p -r -w LYNX2-8-.59F/www/library/implemen/htutils.h
LYNX2-8-/www/library/implemen/htutils.h
--- LYNX2-8-.59F/www/library/implemen/htutils.h Mon Nov 18 19:51:00 2002
+++ LYNX2-8-/www/library/implemen/htutils.h Mon Nov 18 22:37:04 2002
@@ -333,6 +331,10 @@ Macros for declarations
#define typecalloc(cast) (cast *)calloc(1,sizeof(cast))
#define typecallocn(cast,ntypes) (cast
*)calloc(ntypes,sizeof(cast))
+
+/* let they differ from the above */
+#define typeMalloc(cast) (cast *)malloc(sizeof(cast))
+#define typeMallocn(cast,ntypes) (cast
*)malloc(ntypes*sizeof(cast))
/*
diff -u -p -r -w LYNX2-8-.59F/www/library/implemen/htbtree.c
LYNX2-8-/www/library/implemen/htbtree.c
--- LYNX2-8-.59F/www/library/implemen/htbtree.c Mon Nov 18 19:51:00 2002
+++ LYNX2-8-/www/library/implemen/htbtree.c Mon Nov 18 22:36:46 2002
@@ -20,7 +20,7 @@ PUBLIC HTBTree * HTBTree_new ARGS1(HTCom
** for it when given a mean to compare things
*/
{
- HTBTree * tree = (HTBTree *)malloc(sizeof(HTBTree));
+ HTBTree * tree = typeMalloc(HTBTree);
if (tree==NULL) outofmem(__FILE__, "HTBTree_new");
tree->compare = comp;
@@ -153,7 +153,7 @@ PUBLIC void HTBTree_add ARGS2(
if (tree->top == NULL)
{
- tree->top = (HTBTElement *)malloc(sizeof(HTBTElement));
+ tree->top = typeMalloc(HTBTElement);
if (tree->top == NULL) outofmem(__FILE__, "HTBTree_add");
tree->top->up = NULL;
tree->top->object = object;
@@ -179,8 +179,7 @@ PUBLIC void HTBTree_add ARGS2(
else
{
father_found = NO;
- father_of_element->left =
- (HTBTElement *)malloc(sizeof(HTBTElement));
+ father_of_element->left = typeMalloc(HTBTElement);
if (father_of_element->left==NULL)
outofmem(__FILE__, "HTBTree_add");
added_element = father_of_element->left;
@@ -199,8 +198,7 @@ PUBLIC void HTBTree_add ARGS2(
else
{
father_found = NO;
- father_of_element->right =
- (HTBTElement *)malloc(sizeof(HTBTElement));
+ father_of_element->right = typeMalloc(HTBTElement);
if (father_of_element->right==NULL)
outofmem(__FILE__, "HTBTree_add");
added_element = father_of_element->right;
diff -u -p -r -w LYNX2-8-.59F/www/library/implemen/htlist.c
LYNX2-8-/www/library/implemen/htlist.c
--- LYNX2-8-.59F/www/library/implemen/htlist.c Sun Apr 1 17:51:46 2001
+++ LYNX2-8-/www/library/implemen/htlist.c Mon Nov 18 22:36:18 2002
@@ -17,7 +17,7 @@ PUBLIC HTList * HTList_new NOARGS
{
HTList *newList;
- if ((newList = typecalloc(HTList)) == NULL)
+ if ((newList = typeMalloc(HTList)) == NULL)
outofmem(__FILE__, "HTList_new");
newList->object = NULL;
@@ -96,7 +96,7 @@ PUBLIC void HTList_addObject ARGS2(
HTList *newNode;
if (me) {
- if ((newNode = typecalloc(HTList)) == NULL)
+ if ((newNode = typeMalloc(HTList)) == NULL)
outofmem(__FILE__, "HTList_addObject");
newNode->object = newObject;
newNode->next = me->next;
@@ -157,7 +157,7 @@ PUBLIC void HTList_insertObjectAt ARGS3(
prevNode = temp;
while ((temp = temp->next)) {
if (Pos == 0) {
- if ((newNode = typecalloc(HTList)) == NULL)
+ if ((newNode = typeMalloc(HTList)) == NULL)
outofmem(__FILE__, "HTList_addObjectAt");
newNode->object = newObject;
newNode->next = temp;
diff -u -p -r -w LYNX2-8-.59F/src/lystring.c LYNX2-8-/src/lystring.c
--- LYNX2-8-.59F/src/lystring.c Mon Nov 18 19:51:46 2002
+++ LYNX2-8-/src/lystring.c Mon Nov 18 22:35:40 2002
@@ -5449,9 +5449,9 @@ PUBLIC char * SNACopy ARGS3(
{
FREE(*dest);
if (src) {
- *dest = typecallocn(char, n + 1);
+ *dest = typeMallocn(char, n + 1);
if (*dest == NULL) {
- CTRACE((tfp, "Tried to calloc %d bytes\n", n));
+ CTRACE((tfp, "Tried to malloc %d bytes\n", n));
outofmem(__FILE__, "SNACopy");
}
strncpy (*dest, src, n);
@@ -5477,7 +5477,7 @@ PUBLIC char * SNACat ARGS3(
strncpy(*dest + length, src, n);
*(*dest + length + n) = '\0'; /* terminate */
} else {
- *dest = typecallocn(char, n + 1);
+ *dest = typeMallocn(char, n + 1);
if (*dest == NULL)
outofmem(__FILE__, "SNACat");
memcpy(*dest, src, n);
; To UNSUBSCRIBE: Send "unsubscribe lynx-dev" to address@hidden
- lynx-dev Patch for SSL warning, Gisle Vanem, 2002/11/18
- Re: lynx-dev Patch for SSL warning, Leonid Pauzner, 2002/11/18
- Re: lynx-dev Patch for SSL warning, Thomas E. Dickey, 2002/11/18
- Re: lynx-dev Patch for SSL warning, Gisle Vanem, 2002/11/18
- Re: lynx-dev Patch for SSL warning, Thomas E. Dickey, 2002/11/18
- lynx-dev dev.10 progress, Leonid Pauzner, 2002/11/18
- Re: lynx-dev dev.10 progress,
Leonid Pauzner <=
- Re: lynx-dev dev.10 progress, Leonid Pauzner, 2002/11/18
- Re: lynx-dev dev.10 progress, Leonid Pauzner, 2002/11/19
- Re: lynx-dev dev.10 progress, Thomas E. Dickey, 2002/11/19
- Re: lynx-dev dev.10 progress, Leonid Pauzner, 2002/11/19
- Re: lynx-dev dev.10 progress, Thomas E. Dickey, 2002/11/19
- Re: lynx-dev dev.10 progress, Thomas Dickey, 2002/11/19
- Re: lynx-dev dev.10 progress, Leonid Pauzner, 2002/11/20
- Re: lynx-dev dev.10 progress, Thomas Dickey, 2002/11/20
- Re: lynx-dev dev.10 progress, Leonid Pauzner, 2002/11/20
- Re: lynx-dev dev.10 progress, Leonid Pauzner, 2002/11/20