On Mon, 27 Sep 1999, Yee Man Chan wrote:
> Hi,
>
> I am starting to play with Squid source. I am dealing with 2.2S5 and running
> under RedHat Linux 6.0. I ran GNU gdb comes with the distribution to see how
> Squid works. Then I find something I can't explain:
>
> 1. I added a function to Squid that takes a StoreEntry * e as a parameter. I
> find that even if I did nothing to the parameter, when I step through the
> function, the value of the pointer changes. The same thing happens to e->
> mem_obj as well. Why?
Hard to explain without seeing your source code. Could
also be a gdb bug.
> 2. There are xmalloc, xcalloc, xstrncpy, etc... in Squid. I am wondering if
> they are really wrappers of the ANSI C standard library functions. There are
> also others, for example, strcat, strcpy that do not have an x------
> counterpart, why? And why do you define sprintf to unary +, so that we are
> forced (?) to use snprintf defined in lib/snprintf.c?
The 'x' functions exist for different reasons. xmalloc, for example, never
returns NULL. It aborts the process instead. Then I don't have to check
the return value of malloc all the time.
You are forced to use snprintf because sprintf is evil and its use can
lead to buffer-overrun bugs and security holes.
Received on Mon Sep 27 1999 - 20:24:34 MDT
This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:12:17 MST