From: Wojciech Puchar

>>>>>>  if (buffer = NULL) {
>>
>>       if (buffer == NULL) {
>>

> anyway not using malloc is good habit :) but it should work anyway.
> try

The test after the malloc was the problem. I have been working in a
poorly designed scripting language for several months where the single
'=' is used for comparisons and didn't "see" the difference when I got
back into C. Setting a pointer to NULL should always cause an EFAULT.
Unfortunately, even 'gcc -Wall' didn't generate an appropriate warning
for it.

I only use malloc when I won't know how many buffers I need until run
time. In this case the application will count records in a configuration
file and malloc (1514 * count * 2) bytes, where count can range from 1
to 2000. That becomes an array of buffers, so I can pass just an index
or pointer between threads, usually through a mailbox or message queue.
It's a simple trick for message passing that I picked up years ago while
using the CTASK and XINU kernels.

Thanks for all the help,

Bob McConnell
_______________________________________________
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to