Commit 682bbbb4 authored by Jeroen Vreeken's avatar Jeroen Vreeken
Browse files

Since all blocks seem to have a create struct now, we can remove the

compatibility code from controller_block.
Not having a create struct will now lead to failure to load the ctrl file.
parent a599c249
......@@ -50,7 +50,6 @@ static struct calculate_func **calculates = NULL;
static char *controller_block_context = "unknown";
#define BLOCK_PREFIX "block_"
#define BLOCK_POSTFIX "_create"
#define BLOCK_CREATE_POSTFIX "_create_struct"
......@@ -60,11 +59,9 @@ int controller_block_create(char *type, char *name, int argc, va_list ap,
void *handle;
struct controller_block_create *create;
char *prefix = BLOCK_PREFIX;
char *postfix = BLOCK_POSTFIX;
char *postfix_create = BLOCK_CREATE_POSTFIX;
char *symbol;
int ret = 0;
bool create_alloc = false;
handle = dlopen(NULL, RTLD_NOW);
if (!handle) {
......@@ -78,27 +75,6 @@ int controller_block_create(char *type, char *name, int argc, va_list ap,
// Try to load the block's module
create = dlsym(handle, symbol);
free(symbol);
if (!create) {
create = calloc(sizeof(struct controller_block_create) + sizeof(char *) * 2, 1);
if (create == NULL) {
log_send(LOG_T_ERROR, "Out of memory");
ret = -1;
goto err;
}
create_alloc = true;
asprintf(&symbol, "%s%s%s", prefix, type, postfix);
create->create = dlsym(handle, symbol);
create->args[0] = "*";
create->args[1] = NULL;
if (create->create) {
log_send(LOG_T_WARNING,
"block '%s' does not yet provide a "
"controller_block_create structure", type);
}
free(symbol);
}
if (create && create->create) {
ret = controller_load_check_arg(create->args, argc, arg_types);
......@@ -127,8 +103,6 @@ int controller_block_create(char *type, char *name, int argc, va_list ap,
}
err:
if (create_alloc)
free(create);
dlclose(handle);
return ret;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment