find native by name

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%4047
This commit is contained in:
Borja Ferrer 2006-08-01 01:14:54 +00:00
parent a97a3cddb9
commit ba55eab9f5

View File

@ -1,4 +1,5 @@
#include <limits.h> #include <limits.h>
#include <string.h>
#include <assert.h> #include <assert.h>
#include "sp_vm.h" #include "sp_vm.h"
@ -105,3 +106,19 @@ int SP_HeapRelease(sp_context_t *ctx, cell_t local_addr)
return SP_ERR_NONE; return SP_ERR_NONE;
} }
int SP_FindNativeByName(sp_context_t *ctx, const char *name, uint32_t *index)
{
uint32_t i;
for (i = 0; i < ctx->plugin->info->natives_num; i++)
{
if (!strcmp(name, ctx->natives[i].name))
{
if (index)
*index = i;
return SP_ERR_NONE;
}
}
return SP_ERR_NOT_FOUND;
}