diff options
-rwxr-xr-x | main.py | 10 | ||||
-rw-r--r-- | text.py | 6 |
2 files changed, 7 insertions, 9 deletions
@@ -180,10 +180,8 @@ class Argparser(object): parser.add_argument("--verbose", action="store_true", help="verbose", default=False) # TODO parser.add_argument("--forcenullterm", action="store_true", help="terminate all strings with null even if they are not originally null-terminated", default=False) - parser.add_argument("--strbuffersize", type=int, help="the size of the buffer for string reads", default=100) - parser.add_argument("--strbuffgrowfactor", type=float, help="the factor by which the strbuffer will grow", default=1.6) - parser.add_argument("--voidbuffersize", type=int, help="the size of the buffer for void* buffer", default=100) - parser.add_argument("--voidbuffgrowfactor", type=float, help="the factor by which the voidbuffer will grow", default=1.6) + parser.add_argument("--voidtraininitsize", type=int, help="the size of the void train, an integer", default=100) + parser.add_argument("--voidtrainfactor", type=float, help="the factor by which the voidtrain will grow, a float", default=2.0) parser.add_argument("--singlefile", action="store_true", help="the generated code will be put in a single file", default=False) parser.add_argument("--calloc", action="store_true", help="use calloc instead of malloc, defaults to false", default=False) parser.add_argument("--singlefilename", type=str, help="name of the single file") @@ -664,8 +662,8 @@ class CodeGen(object): struct_source_c.write(text.c_read_leb_u_def + "\n") struct_source_c.write(text.c_read_leb_s_def + "\n") struct_source_c.write(text.c_read_until_delimiter + "\n") - if self.argparser.args.calloc: struct_source_c.write(text.c_void_manager.replace("CCC", "ft_calloc") + "\n") - else: struct_source_c.write(text.c_void_manager.replace("CCC", "malloc") + "\n") + if self.argparser.args.calloc: struct_source_c.write(text.c_void_manager.replace("CCC", "ft_calloc").replace("XXX", repr(self.argparser.args.voidtraininitsize)).replace("YYY", repr(self.argparser.args.voidtrainfactor)) + "\n") + else: struct_source_c.write(text.c_void_manager.replace("CCC", "malloc").replace("XXX", repr(self.argparser.args.voidtraininitsize)).replace("YYY", repr(self.argparser.args.voidtrainfactor)) + "\n") struct_source.write("extern void** void_train;\n") struct_source.write("extern uint64_t current_void_size;\n") struct_source.write("extern uint64_t current_void_count;\n") @@ -85,11 +85,11 @@ int32_t read_until_delimiter(int _fd, uint8_t delimiter) { c_void_manager = """ void void_manager(void* ptr, void*** void_train, uint64_t* current_void_size, uint64_t* current_void_count) { if (*current_void_size == 0) { - *void_train = CCC(100*sizeof(void*)); - *current_void_size = 100; + *void_train = CCC(XXX*sizeof(void*)); + *current_void_size = XXX; } if (*current_void_count == *current_void_size) { - *current_void_size*=2; + *current_void_size*=YYY; *void_train = realloc(*void_train, *current_void_size*sizeof(void*)); if (*void_train == NULL) { printf("void train couldnt allocate more memory.\\n"); |