C Structure Pointer Problem
- by Halo
I have this struct;
#define BUFSIZE 10
struct shared_data {
pthread_mutex_t th_mutex_queue;
int count;
int data_buffer_allocation[BUFSIZE];
int data_buffers[BUFSIZE][100];
};
and I want to allocate one of the data_buffers for a process, for that purpose I execute the following function;
int allocate_data_buffer(int pid) {
int i;
for (i = 0; i < BUFSIZE; i++) {
if (sdata_ptr->data_buffer_allocation[i] == NULL) {
sdata_ptr->data_buffer_allocation[i] = pid;
return i;
}
}
return -1;
}
but the compiler warns me that I'm comparing pointer to a value. When I put a & in front of sdata_ptr it calms down but I'm not sure if it will work. Isn't what I wrote above supposed to be true?