0

The problem is - new_handler in OWT_RegistrateHandler always equals &_DummyHandler and i cant understand why. Im tried to disable optimizations and make all variables volatile for debuging. But nothing helps.

Initialization

    static ptr_v_foo_v  handler;
    static ptr_v_foo_v  dummy_handler_ptr = _DummyHandler;
    static ptr_v_foo_v* handlers_list[MAX_HANDLERS];

    memset(handlers_list, 0, (sizeof(handlers_list[0]) * MAX_HANDLERS));                
    handler             = _DummyHandler;
    handlers_list[0]    = &dummy_handler_ptr;

Problem function

    owt_owner OWT_RegistrateHandler(ptr_v_foo_v* new_handler){

    byte i;     

    // Search for occurrence
        for(i = 0; i < MAX_HANDLERS; i++){
            if(handlers_list[i] == new_handler){
                return i;
            }
        }
    // Search for free slot
        for(i = 0; i < MAX_HANDLERS; i++){
            if(handlers_list[i] == 0){
                handlers_list[i] = new_handler;
                return i;
            }
        }
        _ThrowError(OWT_ERROR_MAX_CALLERS);
        return 0;
    }

Function call

    claim_index = OWT_RegistrateHandler(&function_pointer);

Functional description: OWT_RegistrateHandler receive address of function pointer and checks handler_list for same address and free space, after, it write argument to the free `hanler_list' index, and returns this index.

segar
  • 33
  • 6

1 Answers1

1

Ok, the problem was in another static _DummyHandler function. This is stupid, but i missed, that program counter jump in another module, and this module has an error with handler assignment, so it always dummy. Be careful with identical local names. =)

segar
  • 33
  • 6