]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - prvm_edict.c
strncpy -> {strlcpy,memcpy}. Replaced the "forceloop" boolean in "channel_t" by a...
[xonotic/darkplaces.git] / prvm_edict.c
index 4baf85d5e26b3f809bafe3723684153b51b29645..67bc940d36d1938ef66297b4484e02320044103a 100644 (file)
@@ -383,7 +383,7 @@ char *PRVM_ValueString (etype_t type, prvm_eval_t *val)
        switch (type)
        {
        case ev_string:
        switch (type)
        {
        case ev_string:
-               strncpy(line, PRVM_GetString(val->string), sizeof(line));
+               strlcpy (line, PRVM_GetString (val->string), sizeof (line));
                break;
        case ev_entity:
                n = val->edict;
                break;
        case ev_entity:
                n = val->edict;
@@ -470,7 +470,7 @@ char *PRVM_UglyValueString (etype_t type, prvm_eval_t *val)
                break;
        case ev_function:
                f = pr_functions + val->function;
                break;
        case ev_function:
                f = pr_functions + val->function;
-               strncpy(line, PRVM_GetString(f->s_name), sizeof(line));
+               strlcpy (line, PRVM_GetString (f->s_name), sizeof (line));
                break;
        case ev_field:
                def = PRVM_ED_FieldAtOfs ( val->_int );
                break;
        case ev_field:
                def = PRVM_ED_FieldAtOfs ( val->_int );
@@ -595,7 +595,7 @@ void PRVM_ED_Print(prvm_edict_t *ed)
 
                if (strlen(name) > 256)
                {
 
                if (strlen(name) > 256)
                {
-                       strncpy(tempstring2, name, 256);
+                       memcpy (tempstring2, name, 256);
                        tempstring2[256] = tempstring2[257] = tempstring2[258] = '.';
                        tempstring2[259] = 0;
                        name = tempstring2;
                        tempstring2[256] = tempstring2[257] = tempstring2[258] = '.';
                        tempstring2[259] = 0;
                        name = tempstring2;
@@ -608,7 +608,7 @@ void PRVM_ED_Print(prvm_edict_t *ed)
                name = PRVM_ValueString(d->type, (prvm_eval_t *)v);
                if (strlen(name) > 256)
                {
                name = PRVM_ValueString(d->type, (prvm_eval_t *)v);
                if (strlen(name) > 256)
                {
-                       strncpy(tempstring2, name, 256);
+                       memcpy (tempstring2, name, 256);
                        tempstring2[256] = tempstring2[257] = tempstring2[258] = '.';
                        tempstring2[259] = 0;
                        name = tempstring2;
                        tempstring2[256] = tempstring2[257] = tempstring2[258] = '.';
                        tempstring2[259] = 0;
                        name = tempstring2;
@@ -1269,21 +1269,15 @@ void PRVM_LoadProgs (const char * filename, int numrequiredfunc, char **required
        int i;
        dstatement_t *st;
        ddef_t *infielddefs;
        int i;
        dstatement_t *st;
        ddef_t *infielddefs;
-       void *temp;
        dfunction_t *dfunctions;
 
        Mem_EmptyPool(prog->progs_mempool);
        Mem_EmptyPool(prog->edictstring_mempool);
 
        dfunction_t *dfunctions;
 
        Mem_EmptyPool(prog->progs_mempool);
        Mem_EmptyPool(prog->edictstring_mempool);
 
-       temp = FS_LoadFile (filename, false);
-       if (temp == 0)
+       prog->progs = (dprograms_t *)FS_LoadFile (filename, prog->progs_mempool, false);
+       if (prog->progs == NULL)
                PRVM_ERROR ("PRVM_LoadProgs: couldn't load %s for %s", filename, PRVM_NAME);
 
                PRVM_ERROR ("PRVM_LoadProgs: couldn't load %s for %s", filename, PRVM_NAME);
 
-       prog->progs = (dprograms_t *)Mem_Alloc(prog->progs_mempool, fs_filesize);
-
-       memcpy(prog->progs, temp, fs_filesize);
-       Mem_Free(temp);
-
        Con_DPrintf("%s programs occupy %iK.\n", PRVM_NAME, fs_filesize/1024);
 
        pr_crc = CRC_Block((qbyte *)prog->progs, fs_filesize);
        Con_DPrintf("%s programs occupy %iK.\n", PRVM_NAME, fs_filesize/1024);
 
        pr_crc = CRC_Block((qbyte *)prog->progs, fs_filesize);
@@ -1603,7 +1597,7 @@ void PRVM_Fields_f (void)
                }
                if (strlen(name) > 256)
                {
                }
                if (strlen(name) > 256)
                {
-                       strncpy(tempstring2, name, 256);
+                       memcpy (tempstring2, name, 256);
                        tempstring2[256] = tempstring2[257] = tempstring2[258] = '.';
                        tempstring2[259] = 0;
                        name = tempstring2;
                        tempstring2[256] = tempstring2[257] = tempstring2[258] = '.';
                        tempstring2[259] = 0;
                        name = tempstring2;