how to dynamically allocate space for objects of class
Posted: Fri Nov 28, 2008 9:22 pm
i have come to the situation where i have a function kdmalloc which allocates bytes like a usual malloc function and a class disk to read from a disk...the disk read function is working well when i create static objects...now i want to create objects dynamically with malloc
i know that this just reserves some space for disk1 object but doesn't make the function calls to it properly. when i call anyfunction on disk1 that was dynamically created it results in page fault, which means that functions of that object are not setup properly...what should i do to make them work properly ?? should i use new operator, i saw one such implementation of new operator with malloc on osdev wiki, but that too just reserves some space ?? what should i do .??
Code: Select all
disk *disk1 = (disk*) kdmalloc (sizeof(disk));