diff --git a/polymer/eduke32/build/include/osd.h b/polymer/eduke32/build/include/osd.h index 78793201e..6493c24d4 100644 --- a/polymer/eduke32/build/include/osd.h +++ b/polymer/eduke32/build/include/osd.h @@ -274,6 +274,12 @@ int32_t OSD_RegisterCvar(const cvar_t *cvar); void OSD_WriteAliases(FILE *fp); void OSD_WriteCvars(FILE *fp); +static inline void OSD_SetHistory(int32_t histIdx, const char *src) +{ + osd->history.buf[histIdx] = Xmalloc(OSDEDITLENGTH); + Bstrncpyz(osd->history.buf[histIdx], src, OSDEDITLENGTH); +} + // these correspond to the Duke palettes, so they shouldn't really be here // ...but I don't care diff --git a/polymer/eduke32/build/src/config.c b/polymer/eduke32/build/src/config.c index 852790bae..afa398a3c 100644 --- a/polymer/eduke32/build/src/config.c +++ b/polymer/eduke32/build/src/config.c @@ -262,9 +262,8 @@ int32_t loadsetup(const char *fn) // copy script history into OSD history for (i=0; ihistory.maxlines); i++) { -// Bstrncpyz(osd->history.buf[i], scripthist[scripthistend-1-i], OSDEDITLENGTH+1); DO_FREE_AND_NULL(osd->history.buf[i]); - osd->history.buf[i] = Bstrdup(scripthist[scripthistend-1-i]); + OSD_SetHistory(i, scripthist[scripthistend-1-i]); osd->history.lines++; osd->history.total++; diff --git a/polymer/eduke32/build/src/osd.c b/polymer/eduke32/build/src/osd.c index 4cfe65d1c..193c59f8b 100644 --- a/polymer/eduke32/build/src/osd.c +++ b/polymer/eduke32/build/src/osd.c @@ -1127,7 +1127,7 @@ int32_t OSD_HandleChar(char ch) Bmemmove(&osd->history.buf[1], &osd->history.buf[0], sizeof(intptr_t) * osd->history.maxlines-1); - osd->history.buf[0] = Bstrdup(osd->editor.buf); + OSD_SetHistory(0, osd->editor.buf); if (osd->history.lines < osd->history.maxlines) osd->history.lines++;