I am a C++ and Java programmer and I just have a couple simple syntax questions that I can't find a clear answer to. Yes I tried Google.
Question 1: I found the following code on another forum.
typedef struct List
{
char* Name;
char* Address;
BOOL is_present
}List_info;
List_info *List_count[10];
What is the difference between List and List_Info? I was under the impression that List_Info was an instantiated object of type List but it looks like the last line uses List_info as a type not an object. In short what is the diff between List and List_info.
Question 2:
I am trying to write a memory allocator and need an array of pointers that point to Linked List nodes. I wrote the following struct and instantiated the following object in the global space(outside any function definition).
typedef struct LinkedList { //points to the management block
int dManage;
int size;
struct LinkedList* prev;
struct LinkedList* next;
};
struct LinkedList bucketlist[];
The compiler says that on line 8 bucket list has an incomplete type. All I am trying to do is create an Array of pointers to LinkedList structs in the global namespace so other functions can access them but when it needs to be initialized I want to resize the array to be of size numBlocks. I can't seem to find a problem.
extern unsigned int init_allocator(unsigned int _basic_block_size,
unsigned int _length) {
//Computer the max num of uniqe size blocks
unsigned int numBlocks = (int)floor((log((double)_length)/log(2.0))-(log(_basic_block_size)/log(2.0)) + 1);
blockBegin = malloc((size_t)_length); //initialize the first block
struct LinkedList * bucketListTemp[numBlocks];
bucketList = bucketListTemp; //initialize an array of pointers to LL's
bucketList[numBlocks - 1] = blockBegin; //Last element in bucket list is bigest block
bucketList[numBlocks - 1] = bucketList[numBlocks - 1] | 0x01; //set to free
bucketList[numBlocks - 1] = bucketList[numBlocks - 1] | 0x02; //set to no neigbor
I am using GCC btw. Thanks you for any help you can provide.