Run clang format

This commit is contained in:
Melissa LeBlanc-Williams 2024-03-27 13:10:34 -07:00
parent 2850fdeff7
commit b9abc83581
1 changed files with 8 additions and 5 deletions

View File

@ -566,7 +566,8 @@ char *Adafruit_GPS::build(char *nmea, const char *thisSource,
addChecksum(nmea); // Successful completion addChecksum(nmea); // Successful completion
if (!noCRLF) { // Add Carriage Return and Line Feed to comply with NMEA-183 if (!noCRLF) { // Add Carriage Return and Line Feed to comply with NMEA-183
size_t len = strlen(nmea); size_t len = strlen(nmea);
char *newStr = (char *)malloc(len + 3); // +2 for \r\n, +1 for null terminator char *newStr =
(char *)malloc(len + 3); // +2 for \r\n, +1 for null terminator
if (newStr) { if (newStr) {
strcpy(newStr, nmea); // Copy original string strcpy(newStr, nmea); // Copy original string
strcat(newStr, "\r\n"); // Append \r\n strcat(newStr, "\r\n"); // Append \r\n
@ -596,7 +597,8 @@ void Adafruit_GPS::addChecksum(char *buff) {
i++; i++;
} }
// Calculate the needed buffer size: original length + 3 (*XX) + 1 (null terminator) // Calculate the needed buffer size: original length + 3 (*XX) + 1 (null
// terminator)
int neededSize = strlen(buff) + 4; int neededSize = strlen(buff) + 4;
char *tempBuffer = (char *)malloc(neededSize); char *tempBuffer = (char *)malloc(neededSize);
@ -605,7 +607,8 @@ void Adafruit_GPS::addChecksum(char *buff) {
snprintf(tempBuffer, neededSize, "%s*%02X", buff, cs); snprintf(tempBuffer, neededSize, "%s*%02X", buff, cs);
// Copy the formatted string back to the original buffer // Copy the formatted string back to the original buffer
// Note: Make sure the original buffer is large enough to hold the new string. // Note: Make sure the original buffer is large enough to hold the new
// string.
strcpy(buff, tempBuffer); strcpy(buff, tempBuffer);
// Free the allocated memory to avoid memory leaks // Free the allocated memory to avoid memory leaks