RE: Unable to talk to tap(4)



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@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscribe@xxxxxxxxxxx"



Relevant Pages

  • Re: free() performance question
    ... malloc a new space ... and then free the originial two buffers. ... appropriate for clc?" ... How do you find a purple polka dot elephant in a bowl of cherries? ...
    (comp.lang.c)
  • Re: free() performance question
    ... and then free the originial two buffers. ... malloc() function to find them quickly. ... I mean 'balanced (heap) *implementation*'. ... corresponding fast-path for free (or perhaps its only fast-path if you ...
    (comp.lang.c)
  • Re: declaring a function as static..
    ... Sort of forking a copy and reading the results through a pipe (which can ... Long-lived reusable buffers ... other malloc() implementation that caches freed objects to give us back ... We could also malloctwo kstat snapshots, and reuse them every time we ...
    (comp.unix.programmer)
  • Re: free() performance question
    ... malloc a new space ... and then free the originial two buffers. ... I put timer on each step. ... appropriate for clc?" ...
    (comp.lang.c)
  • Re: free() performance question
    ... malloc a new space ... and then free the originial two buffers. ... I put timer on each step. ... for an standard C implementation for DJGPP and others. ...
    (comp.lang.c)