Creating Array of Function pointers dynamically

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi ,

    Iam stuck up with the following problem during modification of a part
of the kernel code.  The problem is to create an "Array of function
pointers dynamically". I tried to solve the problem in this way.

-----------------------------------------------------------------------

int * function(); /*declaration*/

int *(**array_of_function_pointers)(); /*declaration of function pointer 
					array*/

/*The sizeof the array ie (array_of_function_pointers) is not know 
before hand so I need to create dynamically.
 
If the size of array is known then 
"int *(*array_of_function_pointers[SIZE])()" works
*/

/*Allocating memory for array_of_function_pointers */

array_of_function_pointers = (XXXX) malloc(sizeof(YYYY)*SIZE);
                             ------              -----
  
array_of_function_pointers[1]=function;

(*array_of_function_pointers[1])(); /*function call*/

-----------------------------------------------------------------

what should i keep in the place of XXXX and YYYY in the above code.

please help me.

Reguards
Vamsi Krishna

-- 
-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GCS d+ H- s g+++ !p !au a21 w-- v--- C++ U+++ P++ L+++ !3 N--
E- W M- !VMS po+++ t-- !5 !j R- G? !tv b++++
-----END GEEK CODE BLOCK-----

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux