Skip to content

Commit

Permalink
Bug Fixes and Performance Improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
nixrajput committed Jul 23, 2024
1 parent 16b3a3f commit 6dc21ad
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/utils.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef UTILS_H
#define UTILS_H

#include <iostream>
#include <cstdlib>
#include <string>
#include <cstring>
Expand Down Expand Up @@ -37,17 +38,17 @@ string getCurrentDate()
struct tm tStruct;
localtime_s(&tStruct, &t);

return std::to_string(tStruct.tm_mday) + "-" + std::to_string(tStruct.tm_mon + 1) + "-" + std::to_string(tStruct.tm_year + 1900);
return to_string(tStruct.tm_mday) + "-" + to_string(tStruct.tm_mon + 1) + "-" + to_string(tStruct.tm_year + 1900);
}

size_t strlcpy(char *dst, const char *src, size_t dstsize = std::numeric_limits<size_t>::max())
size_t strlcpy(char *dst, const char *src, size_t dstsize = numeric_limits<size_t>::max())
{
size_t srclen = std::strlen(src);
size_t srclen = strlen(src);
size_t copylen = (srclen >= dstsize) ? dstsize - 1 : srclen;

if (dstsize != 0)
{
std::memcpy(dst, src, copylen);
memcpy(dst, src, copylen);
dst[copylen] = '\0'; // Null-terminate the destination buffer
}

Expand Down

0 comments on commit 6dc21ad

Please sign in to comment.