From 4b3c6f13b4745a1f3093e99c3920da4dc50ba61f Mon Sep 17 00:00:00 2001 From: andreas Date: Tue, 24 Oct 2023 16:19:00 +0200 Subject: [PATCH] simplify xdr type mapping --- lib/xdrmappings/GwXDRMappings.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/xdrmappings/GwXDRMappings.cpp b/lib/xdrmappings/GwXDRMappings.cpp index 25d403f..6516f45 100644 --- a/lib/xdrmappings/GwXDRMappings.cpp +++ b/lib/xdrmappings/GwXDRMappings.cpp @@ -55,20 +55,19 @@ GwXDRType *types[] = { new GwXDRType(GwXDRType::GENERIC, "G", ""), new GwXDRType(GwXDRType::DISPLACEMENT, "A", "P"), new GwXDRType(GwXDRType::DISPLACEMENTD, "A", "D",DegToRad,RadToDeg,"rd"), - new GwXDRType(GwXDRType::RPM,"T","R"), - //important to have 2x NULL! - NULL, - NULL}; - + new GwXDRType(GwXDRType::RPM,"T","R") + }; +template +int GetArrLength(T(&)[size]){return size;} static GwXDRType *findType(GwXDRType::TypeCode type, int *start = NULL) { + int len=GetArrLength(types); int from = 0; if (start != NULL) from = *start; - if (types[from] == NULL) - return NULL; + if (from < 0 || from >= len) return NULL; int i = from; - for (; types[i] != NULL; i++) + for (; i< len; i++) { if (types[i]->code == type) {