MCPcopy Create free account
hub / github.com/WheretIB/nullc / nullcLoadModuleByBinary

Function nullcLoadModuleByBinary

NULLC/nullc.cpp:207–238  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

205}
206
207nullres nullcLoadModuleByBinary(const char* module, const char* binary)
208{
209 using namespace NULLC;
210 NULLC_CHECK_INITIALIZED(false);
211
212 if(strlen(module) > 512)
213 {
214 nullcLastError = "ERROR: module name is too long";
215 return false;
216 }
217
218 char path[1024];
219 strcpy(path, module);
220 char *pos = path;
221 while(*pos)
222 if(*pos++ == '.')
223 pos[-1] = '/';
224 strcat(path, ".nc");
225
226 if(BinaryCache::GetBytecode(path))
227 {
228 nullcLastError = "ERROR: module already loaded";
229 return false;
230 }
231 // Duplicate binary
232 char *copy = (char*)NULLC::alloc(((ByteCode*)binary)->size);
233 memcpy(copy, binary, ((ByteCode*)binary)->size);
234 binary = copy;
235 // Load it into cache
236 BinaryCache::PutBytecode(path, binary);
237 return 1;
238}
239
240void nullcRemoveModule(const char* module)
241{

Callers 4

WinMainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
RunInterfaceTestsFunction · 0.85

Calls

no outgoing calls

Tested by 1

RunInterfaceTestsFunction · 0.68