53 lines
798 B
C
53 lines
798 B
C
|
// Copyright © 2017 Project Golan, all rights reserved.
|
||
|
#include "m_str.h"
|
||
|
#include "m_types.h"
|
||
|
|
||
|
#include <Doominati.h>
|
||
|
|
||
|
#include <stdio.h>
|
||
|
#include <stdarg.h>
|
||
|
#include <string.h>
|
||
|
|
||
|
// Extern Functions ----------------------------------------------------------|
|
||
|
|
||
|
//
|
||
|
// M_StrFmt
|
||
|
//
|
||
|
char *M_StrFmt(char const *fmt, ...)
|
||
|
{
|
||
|
[[__no_init]]
|
||
|
static char bufs[3][0x2800];
|
||
|
static int idx;
|
||
|
|
||
|
va_list va;
|
||
|
|
||
|
if(++idx == M_countof(bufs)) idx = 0;
|
||
|
|
||
|
va_start(va, fmt);
|
||
|
vsnprintf(bufs[idx], sizeof(bufs[idx]), fmt, va);
|
||
|
va_end(va);
|
||
|
|
||
|
return bufs[idx];
|
||
|
}
|
||
|
|
||
|
//
|
||
|
// M_StrHash
|
||
|
//
|
||
|
mword M_StrHash(char const *s)
|
||
|
{
|
||
|
mword h = 0;
|
||
|
for(; *s; s++)
|
||
|
h = h * 101 + *s;
|
||
|
return h;
|
||
|
}
|
||
|
|
||
|
//
|
||
|
// M_StrCreate
|
||
|
//
|
||
|
__str M_StrCreate(char const *s)
|
||
|
{
|
||
|
return DGE_String_Create(s, strlen(s));
|
||
|
}
|
||
|
|
||
|
// EOF
|