@anduril462 THanks! yup that was my intention of not having access to the pointer outside that for loop. My worry was that I am not sure whether the pointer declared within each loop will affect the...
Type: Posts; User: Edelweiss
@anduril462 THanks! yup that was my intention of not having access to the pointer outside that for loop. My worry was that I am not sure whether the pointer declared within each loop will affect the...
for(h=0;h<10;h++)
{
testStruct_t* ptyTestStruct;
if(test_FillStruct(&ptyTestStruct)!=test_SUCCESS)
{
free(ptyTestStruct);
}
}
Hi
if i have a for loop and inside the for loop i have a pointer. the declaration, allocating of memory and freeing the pointer is done within the for loop. Will there be any problem? Am I...
oh i see i see. Thanks for the clarifications! =)
oh. I saw this example about char* pointers, hence the question about structs
int my_new(char **obj) {
*obj = malloc(somesize);
}
Hi I want to pass in a struct as an argument in a function, in which this function pass the same struct to another function.
StructExample tyExample;
void function1(&tyExample);
lol. but if i want to use memcmp between an uint8_t array of size 2 and a uint16_t variable, does it still work? since its comparing the memory at the address right?
Hi was wondering if I am comparing 2 char arrays of the same size, can i use memcmp?
Or is there a better way of comparing?
lol ohhh because in my implementation the size of b may varies according to the variable i want to store inside, hence asking about the concept behind struct hack.
c * test = malloc( sizeof...
if its big endian, how do i go about assigning values to it?
just like this?
channels.bB1 = 1
hmm. This will be passed as a byte stream and on the other side, read the byte stream as the same as above
I have a bit field struct as below
typedef struct
{
uint32_t bB0:1;
uint32_t bB1:1;
uint32_t bB2:1;
hmm okie my code goes like this
c* pValue;
pValue= (c*)malloc(2 + sizeof(uint8_t));
pValue->a= 1
uint16_t setValue= 0x1234;
memcpy(c->b,(uint8_t*)&setValue,sizeof(setValue));
Salem, what is the sizeof *test referring to? is it the same as sizeof(c)?
Hi, I am trying to do a struct hack
typedef struct{
uint8_t a;
uint8_t b[1];
}c;
Hi I have a situation here in which i malloc a char_t* pt and free it. If I want to reuse this pt and malloc it of another size. Will there be any risk involved?
If I have the following example
char_t* pbuffer;
pbuffer = (char_t*)malloc(10);
functionTest(pbuffer);
if I have the union in a struct as below
typedef struct{
union{
uint8_t value;
}u;
}s;
typedef struct
{
uint8_t bB0:1;
uint8_t bB1:1;
uint8_t bB2:1;
uint8_t bB3:1;
uint8_t bB4:1;
uint8_t bB5:1;
uint8_t bB6:1;
uint8_t bB7:1;
Thanks!
lolol
oh so if we want to pass a char array into a function, we just have to pass in the name of the array? like in your example?
char_t buffer[10];
somefunction(&buffer);
char_t* pbuffer;
Oh hahaha sorry for the renaming, morning blues.
But if i declare a char* and allocate memory and pass the address of that pointer to a function, what advantages does it has?
Compared the above...
oh the fillupbuffer function basically looks like this
freebuffer(char** buffer)
{
uint16_t a= 1234;
memcpy(*buffer,a,sizeof(uint16_t));
}