Note: I come from a Python / PHP related background and don't have too much experience with C.
I'm currently writing a PHP extension that needs to check if another module is loaded, for this I've copied and pasted the following snippet of code throughout my extension:
#include "php.h"
const char* name = "hash";
if (zend_hash_str_exists(&module_registry, name, sizeof(name) - 1)) {
return; // Doesn't end up here, module is loaded
}
// Returns true and thus ends up here
I decided to put this into it's own method to make my code a lot more clean, however whenever I do this, the method seems to return FALSE
or NULL
. This is the method I'm using:
#include "php.h"
zend_bool extension_module_exists(const char* name)
{
return zend_hash_str_exists(&module_registry, name, sizeof(name) - 1);
}
const char* name = "hash";
if (extension_module_exists(name) == false) {
return; // Now I end up here
}
Could someone give me an indication of what I might be doing wrong? Thank you.