Matching name does not match???
I'll start with the relevant function (as far as I can see):
Code:
void* GetSpotByName( pool_t pool, spot_t *spot, char const *name ) {
size_t i = 0;
static int called = 0;
++called;
spot_t *spots = (spot_t*)pool.list.data.data;
printf( "Call: %d, Name: %s\n", called, name );
for ( ; i < pool.list.used; ++i ) {
if ( !spots[i].data.name ) continue;
printf( "Call: %d, Byte: %zu, Node: %zu, Name: %s\n",
called, spots[i].byte, spots[i].node, spots[i].data.name );
if ( strcmp( spots[i].data.name, name ) == 0 ) {
puts("This one was returned");
if ( spot ) *spot = spots[i];
return spots[i].data.data;
}
}
if ( spot ) memset( spot, 0, sizeof(spot_t) );
return NULL;
}
Now the relevant output:
Code:
...
clang -o mitsy.elf mitsy.o memory.o
./mitsy.elf
mitsy alpha
Opening test.c...
Allocating text buffer...
Passing execution pool & text buffer to compiler...
Entering compiler loop...
Call: 1, Name: int
Call: 1, Byte: 18446744073709551615, Node: 0, Name: test.c
Call: 1, Byte: 0, Node: 1, Name: _start
Call: 1, Byte: 10, Node: 2, Name: exit
Call: 1, Byte: 18446744073709551615, Node: 3, Name: __db
Call: 1, Byte: 18446744073709551615, Node: 4, Name: __dw
Call: 1, Byte: 18446744073709551615, Node: 5, Name: __dd
Call: 1, Byte: 18446744073709551615, Node: 6, Name: __dq
Call: 1, Byte: 18446744073709551615, Node: 7, Name: char
Call: 1, Byte: 18446744073709551615, Node: 8, Name: short
Call: 1, Byte: 18446744073709551615, Node: 9, Name: int
Call: 1, Byte: 18446744073709551615, Node: 10, Name: signed
Call: 1, Byte: 18446744073709551615, Node: 11, Name: unsigned
Call: 1, Byte: 18446744073709551615, Node: 12, Name: long long
Call: 1, Byte: 18446744073709551615, Node: 13, Name: float
Call: 1, Byte: 18446744073709551615, Node: 14, Name: double
Call: 1, Byte: 18446744073709551615, Node: 15, Name: long
test.c:0:0:0, Unkown Type int
Compilation Failed: ret = 1, errno = 0
makefile:41: recipe for target 'run' failed
make: *** [run] Error 1
Compilation failed.
As you will notice the program unexpectedly ignores the correct result leaving me confused as why it's doing so,
I check the docs of strcmp() and I'm using it right so I haven't been able to identify the error in my code, I even tried switching my ctx->text[len] = 0 for ctx->text[len] = '\0' before passing it to this function and still same output.