-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
replaced strlcat with compat function
Closes #8
- Loading branch information
Showing
7 changed files
with
66 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// | ||
// Created by Michael Henderson on 11/14/23. | ||
// | ||
|
||
#include "memsafe.h" | ||
|
||
// zstrcpy safely copies a c-string from src to dst, taking care | ||
// to avoid overflow and to always terminate the destination. | ||
// The "size" parameter is the size (in bytes) of the destination. | ||
// if the source is shorter than the destination, the remainder | ||
// of the destination will be filled with zeroes. | ||
int zstrcpy(char *dst, const char *src, size_t size) { | ||
int s = 0; // index into source buffer | ||
int d = 0; // index into destination buffer | ||
if (size > 0) { | ||
for (; d < size; d++) { | ||
dst[d] = src[s]; | ||
if (src[s] != 0) { | ||
s++; | ||
} | ||
} | ||
dst[size-1] = 0; | ||
} | ||
return s; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Far Horizons Game Engine | ||
// Copyright (c) 2023 Michael D Henderson | ||
// Copyright (C) 2021 Raven Zachary | ||
// Copyright (C) 2019 Casey Link, Adam Piggott | ||
// Copyright (C) 1999 Richard A. Morneau | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
// | ||
// Created by Michael Henderson on 11/14/23. | ||
// | ||
|
||
#ifndef FAR_HORIZONS_MEMSAFE_H | ||
#define FAR_HORIZONS_MEMSAFE_H | ||
|
||
#include <stddef.h> | ||
|
||
// memory safe c-string copy, copied from strlcat | ||
int zstrcpy(char *dst, const char *src, size_t size); | ||
|
||
#endif //FAR_HORIZONS_MEMSAFE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,7 +48,7 @@ int versionCommand(int argc, char *argv[]) { | |
} | ||
} | ||
|
||
printf("7.5.7\n"); | ||
printf("7.5.9\n"); | ||
|
||
return 2; | ||
} |