Project Home
Project Home
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - malloc() and free() with more than 1 arg.: (3 Items)
   
malloc() and free() with more than 1 arg.  
Hello.

I'm writting an iopkt driver based on speedo model.
I'm porting a code from io-net.

io-pkt drivers expects malloc and free with more than 1 arg such as :
free(freeptr, M_TEMP);
malloc(strlen(optstring) + 1, M_TEMP, M_NOWAIT);

wereas doc is saying :
Synopsis:

#include <stdlib.h>

void* malloc( size_t size );

Arguments:

size
    The number of bytes to allocate.

Where does this macro are defined ?
Is it possible to do not use them ?

Thanks.
Guillaume
Re: malloc() and free() with more than 1 arg.  
I Found the reason : _KERNEL is defined.

Is _KERNEL define mandatory to build io-pkt driver?

Thanks,
Gui.
RE: malloc() and free() with more than 1 arg.  
Hi Guillaume:
  One of the goals of the io-pkt design was to re-use as much of the NetBSD code as possible with as few changes as 
possible.  NetBSD being a monolithic kernel design has all of the network stack (and drivers) running in the kernel (and
 this is why the KERNEL macro is defined).  So the short answer is that you should use the malloc and free API in an 
identical manner to the drivers that are already there.

Now, that being said, I believe that the re-defines from the POSIX API to the NetBSD API comes from muf.h (although I 
can't remember for sure).  So if you don't have any mbuf accesses in your file (and you haven't included any of the 
headers that pull in mbuf.h (which isn't going to be easy... trust me...)) then you might just be able to use straight 
malloc calls.  I wouldn't advise it though.

   Robert.

-----Original Message-----
From: Guillaume Varlet [mailto:community-noreply@qnx.com]
Sent: Mon 4/27/2009 6:12 AM
To: ionetmig-networking
Subject: malloc() and free() with more than 1 arg.
 
Hello.

I'm writting an iopkt driver based on speedo model.
I'm porting a code from io-net.

io-pkt drivers expects malloc and free with more than 1 arg such as :
free(freeptr, M_TEMP);
malloc(strlen(optstring) + 1, M_TEMP, M_NOWAIT);

wereas doc is saying :
Synopsis:

#include <stdlib.h>

void* malloc( size_t size );

Arguments:

size
    The number of bytes to allocate.

Where does this macro are defined ?
Is it possible to do not use them ?

Thanks.
Guillaume

_______________________________________________
io-net migration
http://community.qnx.com/sf/go/post28109


Attachment: Text winmail.dat 3.35 KB