Update tuple storage functions

This commit is contained in:
Will Hedgecock 2021-11-08 12:50:17 -06:00
parent 24e5e14a6d
commit 6ab8a2380a
3 changed files with 15 additions and 14 deletions

View File

@ -2,7 +2,7 @@
* SerialPort_Windows.c
*
* Created on: Feb 25, 2012
* Last Updated on: Nov 01, 2021
* Last Updated on: Nov 03, 2021
* Author: Will Hedgecock
*
* Copyright (C) 2012-2021 Fazecast, Inc.
@ -107,7 +107,7 @@ JNIEXPORT jobjectArray JNICALL Java_com_fazecast_jSerialComm_SerialPort_getCommP
wchar_t* descriptionString = wcsrchr(valueName, L'\\') ? (wcsrchr(valueName, L'\\') + 1) : valueName;
// Add new SerialComm object to vector
push_back(&serialCommPorts, comPortString, descriptionString, descriptionString);
pushBack(&serialCommPorts, comPortString, descriptionString, descriptionString);
}
}

View File

@ -2,10 +2,10 @@
* WindowsHelperFunctions.c
*
* Created on: May 05, 2015
* Last Updated on: Mar 25, 2016
* Last Updated on: Nov 03, 2021
* Author: Will Hedgecock
*
* Copyright (C) 2012-2020 Fazecast, Inc.
* Copyright (C) 2012-2021 Fazecast, Inc.
*
* This file is part of jSerialComm.
*
@ -28,7 +28,7 @@
#include <string.h>
#include "WindowsHelperFunctions.h"
void push_back(struct charTupleVector* vector, const wchar_t* firstString, const wchar_t* secondString, const wchar_t* thirdString)
void pushBack(struct charTupleVector* vector, const wchar_t* key, const wchar_t* firstString, const wchar_t* secondString)
{
// Allocate memory for new string storage
vector->length++;
@ -43,12 +43,12 @@ void push_back(struct charTupleVector* vector, const wchar_t* firstString, const
vector->third = newMemory;
// Store new strings
vector->first[vector->length-1] = (wchar_t*)malloc((wcslen(firstString)+1)*sizeof(wchar_t));
vector->second[vector->length-1] = (wchar_t*)malloc((wcslen(secondString)+1)*sizeof(wchar_t));
vector->third[vector->length-1] = (wchar_t*)malloc((wcslen(thirdString)+1)*sizeof(wchar_t));
wcscpy(vector->first[vector->length-1], firstString);
wcscpy(vector->second[vector->length-1], secondString);
wcscpy(vector->third[vector->length-1], thirdString);
vector->first[vector->length-1] = (wchar_t*)malloc((wcslen(key)+1)*sizeof(wchar_t));
vector->second[vector->length-1] = (wchar_t*)malloc((wcslen(firstString)+1)*sizeof(wchar_t));
vector->third[vector->length-1] = (wchar_t*)malloc((wcslen(secondString)+1)*sizeof(wchar_t));
wcscpy(vector->first[vector->length-1], key);
wcscpy(vector->second[vector->length-1], firstString);
wcscpy(vector->third[vector->length-1], secondString);
}
char keyExists(struct charTupleVector* vector, const wchar_t* key)

View File

@ -2,10 +2,10 @@
* WindowsHelperFunctions.h
*
* Created on: May 05, 2015
* Last Updated on: Apr 01, 2018
* Last Updated on: Nov 03, 2021
* Author: Will Hedgecock
*
* Copyright (C) 2012-2020 Fazecast, Inc.
* Copyright (C) 2012-2021 Fazecast, Inc.
*
* This file is part of jSerialComm.
*
@ -31,7 +31,8 @@ typedef struct charTupleVector
wchar_t **first, **second, **third;
size_t length;
} charTupleVector;
void push_back(struct charTupleVector* vector, const wchar_t* firstString, const wchar_t* secondString, const wchar_t* thirdString);
void pushBack(struct charTupleVector* vector, const wchar_t* key, const wchar_t* firstString, const wchar_t* secondString);
char keyExists(struct charTupleVector* vector, const wchar_t* key);
#endif // #ifndef __WINDOWS_HELPER_FUNCTIONS_HEADER_H__