stralloc?

2001-02-27 Thread tc lewis


has any thought been put into releasing the stralloc library/interface by
itself?  qmail's stralloc files appear a bit different than djbdns', and
i'm unsure about the ones in other packages, but stralloc could be rather
useful for developers of other projects.

sorry that this is to the qmail list.  none of the cr.yp.to lists were
very relevant.

-tcl.





Re: stralloc problem

2000-05-04 Thread Daniel Neri

"Petr Novotny" [EMAIL PROTECTED] writes:

 You may want to read the source of the function, I would think. Or 
 find a documentation.

http://cr.yp.to/lib/stralloc.html


Regards,
/Daniel

-- 
Daniel Neri
Signalteknik AB, Sweden




Re: stralloc problem

2000-05-02 Thread Federico Barbazza

Petr Novotny wrote:
 
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1
 
 On 2 May 00, at 15:21, Federico Barbazza wrote:
 
  Hi all,
  if in qmail-pop3d i declared a variable:
 
  stralloc *arrayname;
  int numm = 30;
  arrayname = (stralloc *) alloc(numm * sizeof(stralloc))
 
 Does alloc() initialize the memory it allocates? To which value?
how can i see??
 
  for (i=0; inumm; i++)
  stralloc_copys(arrayname[i], "hello");
 
  This code exit with a "segmentation fault" sometimes immediatly
  sometimes when i = 2.
  Is it a memory problem??
 
 Whose memory? :-)
 
 Looks like the memory is initialized to arbitrary values, sometimes -
 - - by chance - to NULL or something, and therefore not crashing.
I saw stralloc are initializate as:
stralloc variable = {0}.
How can i initialize my stralloc array??


 
 -BEGIN PGP SIGNATURE-
 Version: PGP 6.0.2 -- QDPGP 2.60
 Comment: http://community.wow.net/grt/qdpgp.html
 
 iQA/AwUBOQ7JVlMwP8g7qbw/EQJ1GQCg36xGK+18R+uY62Eo+rxc6eswuQwAoNh2
 WbTpXM7VVTQtI0rPGCE6QMXj
 =O9kb
 -END PGP SIGNATURE-
 --
 Petr Novotny, ANTEK CS
 [EMAIL PROTECTED]
 http://www.antek.cz
 PGP key ID: 0x3BA9BC3F
 -- Don't you know there ain't no devil there's just God when he's drunk.
  [Tom Waits]



Re: stralloc problem

2000-05-02 Thread Petr Novotny

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 2 May 00, at 15:21, Federico Barbazza wrote:

 Hi all,
 if in qmail-pop3d i declared a variable:
 
 stralloc *arrayname;
 int numm = 30;
 arrayname = (stralloc *) alloc(numm * sizeof(stralloc))

Does alloc() initialize the memory it allocates? To which value?

 for (i=0; inumm; i++)
 stralloc_copys(arrayname[i], "hello");
 
 This code exit with a "segmentation fault" sometimes immediatly
 sometimes when i = 2.
 Is it a memory problem??

Whose memory? :-)


Looks like the memory is initialized to arbitrary values, sometimes -
- - by chance - to NULL or something, and therefore not crashing.

-BEGIN PGP SIGNATURE-
Version: PGP 6.0.2 -- QDPGP 2.60 
Comment: http://community.wow.net/grt/qdpgp.html

iQA/AwUBOQ7JVlMwP8g7qbw/EQJ1GQCg36xGK+18R+uY62Eo+rxc6eswuQwAoNh2
WbTpXM7VVTQtI0rPGCE6QMXj
=O9kb
-END PGP SIGNATURE-
--
Petr Novotny, ANTEK CS
[EMAIL PROTECTED]
http://www.antek.cz
PGP key ID: 0x3BA9BC3F
-- Don't you know there ain't no devil there's just God when he's drunk.
 [Tom Waits]



stralloc problem

2000-05-02 Thread Federico Barbazza

Hi all,
if in qmail-pop3d i declared a variable:

stralloc *arrayname;
int numm = 30;
arrayname = (stralloc *) alloc(numm * sizeof(stralloc))
for (i=0; inumm; i++)
stralloc_copys(arrayname[i], "hello");

This code exit with a "segmentation fault" sometimes immediatly
sometimes when i = 2.
Is it a memory problem??
Thanks for all your suggest

Federico.



Re: stralloc problem

2000-05-02 Thread Petr Novotny

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On 2 May 00, at 15:36, Federico Barbazza wrote:

   stralloc *arrayname;
   int numm = 30;
   arrayname = (stralloc *) alloc(numm * sizeof(stralloc))
  
  Does alloc() initialize the memory it allocates? To which value?

 how can i see??

What? You're using a function and you don't know what the 
function does??? Oh God!

You may want to read the source of the function, I would think. Or 
find a documentation.

   for (i=0; inumm; i++)
   stralloc_copys(arrayname[i], "hello");
  
   This code exit with a "segmentation fault" sometimes immediatly
   sometimes when i = 2. Is it a memory problem??
  
  Looks like the memory is initialized to arbitrary values, sometimes
  - - - by chance - to NULL or something, and therefore not crashing.
 I saw stralloc are initializate as:
 stralloc variable = {0}.
 How can i initialize my stralloc array??

memset(arrayname,0,numm*sizeof(arrayname[0])); is a way.

-BEGIN PGP SIGNATURE-
Version: PGP 6.0.2 -- QDPGP 2.60 
Comment: http://community.wow.net/grt/qdpgp.html

iQA/AwUBOQ7M0lMwP8g7qbw/EQJlMACeLVqA6403eVTwvIT/hR5Eeqx5E4MAoOgF
WZxhTY93ZON1sCUocVPYgD95
=AMMI
-END PGP SIGNATURE-
--
Petr Novotny, ANTEK CS
[EMAIL PROTECTED]
http://www.antek.cz
PGP key ID: 0x3BA9BC3F
-- Don't you know there ain't no devil there's just God when he's drunk.
 [Tom Waits]



qmail-pop3d stralloc problem

2000-05-01 Thread Federico Barbazza

Hi all,
i have a big program with stralloc variable.
So, in qmail-pop3d i declared a variable:
stralloc *arrayname;
arrayname = (stralloc *) alloc(numm * sizeof(stralloc))
with numm as number of message.
When i try to do a stralloc_copys(arrayname[i], "hello"), qmail-pop3d
exit with a "segmentation fault".
The strange thing is that i get this error only when numm is great than
25.I thought ...may be a memory problemor most probably i'm not a
really good c programmer.

Thanks for all your suggest

Federico.



Re: qmail-pop3d stralloc problem

2000-05-01 Thread markd

On Mon, May 01, 2000 at 10:19:57PM +0200, Federico Barbazza wrote:
 Hi all,
 i have a big program with stralloc variable.
 So, in qmail-pop3d i declared a variable:
 stralloc *arrayname;
 arrayname = (stralloc *) alloc(numm * sizeof(stralloc))

Is that the exact code?

If so, should be it sizeof(stralloc) be the sizeof the structure you
are playing with?

 with numm as number of message.
 When i try to do a stralloc_copys(arrayname[i], "hello"), qmail-pop3d
 exit with a "segmentation fault".
 The strange thing is that i get this error only when numm is great than
 25.I thought ...may be a memory problemor most probably i'm not a
 really good c programmer.
 
 Thanks for all your suggest
 
 Federico.



Re: qmail-pop3d stralloc problem

2000-05-01 Thread markd

On Mon, May 01, 2000 at 01:22:32PM -0700, [EMAIL PROTECTED] wrote:
 On Mon, May 01, 2000 at 10:19:57PM +0200, Federico Barbazza wrote:
  Hi all,
  i have a big program with stralloc variable.
  So, in qmail-pop3d i declared a variable:
  stralloc *arrayname;
  arrayname = (stralloc *) alloc(numm * sizeof(stralloc))
 
 Is that the exact code?
 
 If so, should be it sizeof(stralloc) be the sizeof the structure you
 are playing with?

Hoy! - where did that typo come from? I meant to say,
should the sizeof(stralloc) be sizeof(yourstructure). I hope that
was clear.



Re: qmail-pop3d stralloc problem

2000-05-01 Thread Federico Barbazza

[EMAIL PROTECTED] wrote:
 
 On Mon, May 01, 2000 at 01:22:32PM -0700, [EMAIL PROTECTED] wrote:
  On Mon, May 01, 2000 at 10:19:57PM +0200, Federico Barbazza wrote:
   Hi all,
   i have a big program with stralloc variable.
   So, in qmail-pop3d i declared a variable:
   stralloc *arrayname;
   arrayname = (stralloc *) alloc(numm * sizeof(stralloc))
 
  Is that the exact code?
 
  If so, should be it sizeof(stralloc) be the sizeof the structure you
  are playing with?
 
 Hoy! - where did that typo come from? I meant to say,
 should the sizeof(stralloc) be sizeof(yourstructure). I hope that
 was clear.

stralloc is a structure with a int and a char*
now i tried to do this declaration:
struct stralloc *arrayname;
struct arrayname = (struct stralloc *) alloc(numm *sizeof(struct
stralloc))
but it doesn't work.
Thanks anyway.



stralloc allocation

1999-08-28 Thread Daemeon Reiydelle

While on the subject of stralloc'ed structures: have you thought of
setting them to a fairly large value (e.g. 256 or 512 or the requeste
value, whichever is larger) when allocated? I know the stralloc_ready
can be used if you know the value will be large, but I have seen enough
byte-by-byte copy loops that it looked like a good idea to preallocate
(memory is cheap). I haven't torn into stralloc function in detail,
rather just what I saw while fixing my own code in the debugger, and a
quick look at the stralloc_ready et al code.

I seem to recall an CompSci algorithm to remember the last allocation,
then reallocate twice the space when the current area runs out of room.

-- 
Daemeon Reiydelle
Systems Engineer, Anthropomorphics Inc.
[EMAIL PROTECTED]



Re: stralloc allocation

1999-08-28 Thread Russell Nelson

Daemeon Reiydelle writes:
  While on the subject of stralloc'ed structures: have you thought of
  setting them to a fairly large value (e.g. 256 or 512 or the requeste
  value, whichever is larger) when allocated?

30.

-- 
-russ nelson [EMAIL PROTECTED]  http://russnelson.com
Crynwr sells support for free software  | PGPok | Government schools are so
521 Pleasant Valley Rd. | +1 315 268 1925 voice | bad that any rank amateur
Potsdam, NY 13676-3213  | +1 315 268 9201 FAX   | can outdo them. Homeschool!



stralloc

1999-06-14 Thread Van Liedekerke Franky

Hi,

maybe this is a stupid question, but my C knowledge is not that big, so I'm
asking it anyways:
There are a lot of stralloc calls in qmail, does this memory never needs to
be freed again? 

Franky



Re: stralloc

1999-06-14 Thread Harald Hanche-Olsen

+ Van Liedekerke Franky [EMAIL PROTECTED]:

| maybe this is a stupid question, but my C knowledge is not that big,
| so I'm asking it anyways:
| There are a lot of stralloc calls in qmail, does this memory never
| needs to be freed again?

Most of the time, it's freed by the most efficient algorithm
imaginable: _exit.  Thanks to qmail's highly modular structure, most
qmail programs don't live long enough for the concept of memory leaks
to even apply.  If you look in the long-running programs, though, you
will probably find that strings are not allocated frivolously.  I have
never bothered to look carefully, but neither have I seen any signs of
the long-running daemons bloating with time.

- Harald



Re: stralloc

1999-06-14 Thread Andre Oppermann

Van Liedekerke Franky wrote:
 
 Hi,
 
 maybe this is a stupid question, but my C knowledge is not that big, so I'm
 asking it anyways:
 There are a lot of stralloc calls in qmail, does this memory never needs to
 be freed again?

Most of the time not because most programs live only for one delivery
(eg. qmail-lspawn, qmail-rspawn, qmail-local, qmail-smtpd... etc.), so
memory will be freed anyway on the exit of the program.

It matters only in long living daemons like qmail-send.

-- 
Andre



Re: stralloc

1999-06-14 Thread Fred Lindberg

On Mon, 14 Jun 1999 14:20:02 +0200, Van Liedekerke Franky wrote:

There are a lot of stralloc calls in qmail, does this memory never needs to
be freed again? 

All strallocs are either global or static in subroutines. Look at
alloc.c/alloc_re.c. They allocate new memory only if needed and if a
string grows, the old memory is freed. Thus, at most you end up with
memory allocated for each "stralloc" that corresponds to the largest
string it has held. There are no leaks.

As mentioned in other posts, the memory is freed when the program
exits.

-Sincerely, Fred

(Frederik Lindberg, Infectious Diseases, WashU, St. Louis, MO, USA)