This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Dynamic malloc problem


clifford.smith wrote:
> sine I allocate memory with malloc for table in the main() it
> works perfectcly. As soon as I try to allocate this memory in
> a function (void my_funct() ... ) I get a segm. fault.
>
> What can I do. Is there another way to dynamicaly allocate mem ?

The fault is in your code.  There is absolutely no reason why you shouldn't
be able to malloc() in a function other than main().  Look for bugs.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]