]> git.xonotic.org Git - xonotic/gmqcc.git/blobdiff - ir.c
Apply some static where it belongs
[xonotic/gmqcc.git] / ir.c
diff --git a/ir.c b/ir.c
index e794860f078a998cbe1694799574cc55fec99d7a..68186dc3dfa5cfcc5bb6d8fc6e2935913aaf6f6e 100644 (file)
--- a/ir.c
+++ b/ir.c
@@ -48,7 +48,7 @@ const char *type_name[TYPE_COUNT] = {
     "<no-expression>"
 };
 
-size_t type_sizeof_[TYPE_COUNT] = {
+static size_t type_sizeof_[TYPE_COUNT] = {
     1, /* TYPE_VOID     */
     1, /* TYPE_STRING   */
     1, /* TYPE_FLOAT    */
@@ -1206,22 +1206,11 @@ bool ir_value_set_field(ir_value *self, ir_value *fld)
     return true;
 }
 
-static char *ir_strdup(const char *str)
-{
-    if (str && !*str) {
-        /* actually dup empty strings */
-        char *out = (char*)mem_a(1);
-        *out = 0;
-        return out;
-    }
-    return util_strdup(str);
-}
-
 bool ir_value_set_string(ir_value *self, const char *str)
 {
     if (self->vtype != TYPE_STRING)
         return false;
-    self->constval.vstring = ir_strdup(str);
+    self->constval.vstring = util_strdupe(str);
     self->hasvalue = true;
     return true;
 }
@@ -1651,7 +1640,7 @@ void ir_phi_add(ir_instr* self, ir_block *b, ir_value *v)
          * is doing something wrong.
          */
         irerror(self->context, "Invalid entry block for PHI");
-        abort();
+        exit(EXIT_FAILURE);
     }
 
     pe.value = v;
@@ -3070,7 +3059,7 @@ static ir_value* ir_gen_extparam_proto(ir_builder *ir)
     ir_value *global;
     char      name[128];
 
-    snprintf(name, sizeof(name), "EXTPARM#%i", (int)(vec_size(ir->extparam_protos)));
+    util_snprintf(name, sizeof(name), "EXTPARM#%i", (int)(vec_size(ir->extparam_protos)));
     global = ir_value_var(name, store_global, TYPE_VECTOR);
 
     vec_push(ir->extparam_protos, global);
@@ -3151,14 +3140,14 @@ static bool gen_function_varargs_copy(ir_function *self)
     stmt.o3.s1 = 0;
     maxparams = numparams + self->max_varargs;
     for (i = numparams; i < maxparams; ++i) {
-        if (i <= 8) {
+        if (i < 8) {
             stmt.o1.u1 = OFS_PARM0 + 3*i;
             stmt.o2.u1 = ir_value_code_addr(self->locals[i]);
             code_push_statement(&stmt, self->context.line);
             continue;
         }
-        ext = i - 9;
-        if (ext >= vec_size(ir->extparams))
+        ext = i - 8;
+        while (ext >= vec_size(ir->extparams))
             ir_gen_extparam(ir);
 
         ep = ir->extparams[ext];
@@ -3292,6 +3281,8 @@ static void gen_vector_defs(prog_section_def def, const char *name)
         def.offset++;
         component[len-1]++;
     }
+
+    mem_d(component);
 }
 
 static void gen_vector_fields(prog_section_field fld, const char *name)
@@ -3320,6 +3311,8 @@ static void gen_vector_fields(prog_section_field fld, const char *name)
         fld.offset++;
         component[len-1]++;
     }
+
+    mem_d(component);
 }
 
 static bool ir_builder_gen_global(ir_builder *self, ir_value *global, bool islocal)
@@ -3819,7 +3812,7 @@ void ir_function_dump(ir_function *f, char *ind,
     }
     if (vec_size(f->blocks))
     {
-        oprintf("%slife passes: %i\n", ind, (int)f->run_id); 
+        oprintf("%slife passes: %i\n", ind, (int)f->run_id);
         for (i = 0; i < vec_size(f->blocks); ++i) {
             ir_block_dump(f->blocks[i], ind, oprintf);
         }