mirror of
https://github.com/zeldaret/ss
synced 2026-05-25 07:23:00 -04:00
Expatriate the inline string methods
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
#ifndef INLINE_STRING_H
|
||||
#define INLINE_STRING_H
|
||||
|
||||
#include <MSL_C/string.h>
|
||||
|
||||
inline void inline_strncat(char *dest, const char *src, size_t destSize) {
|
||||
if (src != nullptr) {
|
||||
size_t destLen = strlen(dest);
|
||||
size_t copyLen = strlen(src);
|
||||
|
||||
// Make sure copy length isnt more than destination length
|
||||
if (destLen + copyLen + 1 >= destSize) {
|
||||
copyLen = destSize - destLen - 1;
|
||||
}
|
||||
|
||||
strncpy(dest + destLen, src, copyLen);
|
||||
|
||||
// make sure string is null terminated
|
||||
size_t offset = destLen + copyLen;
|
||||
dest[offset] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
inline void inline_strncpy(char *dest, const char *src, size_t destSize) {
|
||||
if (src != dest) {
|
||||
dest[0] = '\0';
|
||||
inline_strncat(dest, src, destSize);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
+1
-29
@@ -1,8 +1,6 @@
|
||||
#include <d/d_rawarchive.h>
|
||||
#include <inline_string.h>
|
||||
#include <rvl/VI.h>
|
||||
// clang-format off
|
||||
#include <MSL_C/string.h>
|
||||
// clang-format on
|
||||
|
||||
class UnkManager {
|
||||
public:
|
||||
@@ -133,32 +131,6 @@ bool dRawArcEntry_c::loadArcFromDiskChecked(const char *fileName, const char *di
|
||||
return false;
|
||||
}
|
||||
|
||||
// Regswap
|
||||
inline void inline_strncat(char *dest, const char *src, size_t destSize) {
|
||||
if (src != nullptr) {
|
||||
size_t destLen = strlen(dest);
|
||||
size_t copyLen = strlen(src);
|
||||
|
||||
// Make sure copy length isnt more than destination length
|
||||
if (destLen + copyLen + 1 >= destSize) {
|
||||
copyLen = destSize - destLen - 1;
|
||||
}
|
||||
|
||||
strncpy(dest + destLen, src, copyLen);
|
||||
|
||||
// make sure string is null terminated
|
||||
size_t offset = destLen + copyLen;
|
||||
dest[offset] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
inline void inline_strncpy(char *dest, const char *src, size_t destSize) {
|
||||
if (src != dest) {
|
||||
dest[0] = '\0';
|
||||
inline_strncat(dest, src, destSize);
|
||||
}
|
||||
}
|
||||
|
||||
bool dRawArcEntry_c::loadArcFromDisk(const char *arcName, const char *arcPath, u8 mountDirection, EGG::Heap *heap) {
|
||||
mpDvdReq = mDvd_mountMemArchive_c::create(arcPath, mountDirection, heap);
|
||||
if (mpDvdReq == nullptr) {
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
#include "toBeSorted/file_manager.h"
|
||||
#include "f/f_base.h"
|
||||
#include <m/m_heap.h>
|
||||
// #include "libc.h"
|
||||
#include <MSL_C/string.h>
|
||||
#include <inline_string.h>
|
||||
|
||||
// This class here makes no sense and the name might
|
||||
// be a total misnomer, but this gets the sinit section correct
|
||||
@@ -142,7 +141,7 @@ inline void strnsth(char *dest, const char *src, size_t max_len) {
|
||||
|
||||
char buf[0x20];
|
||||
buf[0] = '\0';
|
||||
strnsth(buf, "F405", 0x20);
|
||||
inline_strncpy(buf, "F405", sizeof(buf));
|
||||
file->setAreaT1(buf);
|
||||
file->room_id_t1 = 0;
|
||||
file->forced_layer_t1 = 0;
|
||||
|
||||
Reference in New Issue
Block a user