• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

nasa / trick / 25459968639

06 May 2026 08:42PM UTC coverage: 55.916% (-0.8%) from 56.7%
25459968639

Pull #2011

github

web-flow
Merge f11412d5f into 7054e405e
Pull Request #2011: Single-file CI and code style adoption

14607 of 26123 relevant lines covered (55.92%)

466416.66 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

61.11
/trick_source/sim_services/MemoryManager/MemoryManager_add_var.cpp
1

2
#include <string.h>
3
#include <ctype.h>
4
#include <stdlib.h>
5
#include <iostream>
6
#include <sstream>
7

8
#include "trick/value.h"
9
#include "trick/vval.h"
10
#include "trick/MemoryManager.hh"
11

12
void* Trick::MemoryManager::add_var( TRICK_TYPE   type,
1,704✔
13
                                     const char*  class_name,
14
                                     VAR_DECLARE* var_declare,
15
                                     char*        units __attribute__ ((unused))) {
16

17
    int ii;
18
    int n_stars;
19
    int n_cdims;
20
    int cdims[TRICK_MAX_INDEX];
21
    VARIABLE_MAP::iterator variable_pos;
1,704✔
22
    std::string class_name_string;
1,704✔
23
    void* address;
24

25
    /** @par Design Details: */
26

27
    class_name_string = "";
1,704✔
28
    if (class_name) {
1,704✔
29
        class_name_string = class_name;
129✔
30
    }
31

32
    /** @li Determine whether the name of the given variable declaration is already in use. */
33
    pthread_mutex_lock(&mm_mutex);
1,704✔
34
    variable_pos = variable_map.find( var_declare->name);
3,408✔
35
    if (variable_pos != variable_map.end()) {
1,704✔
36
        std::stringstream ss;
×
37
        ss << "Variable \""<<  var_declare->name << "\" is already declared.\n";
×
38
        emitError(ss.str());
×
39
        pthread_mutex_unlock(&mm_mutex);
×
40
        return ((void*)NULL);
×
41
    }
×
42
    pthread_mutex_unlock(&mm_mutex);
1,704✔
43

44
    /** @li From VAR_DECLARE, extract: 1) unconstrained dimensions
45
        (i.e., n_stars) and 2) constrain dimensions (i.e., ndims, dims[]). */
46
    n_stars = var_declare->num_pointers;
1,704✔
47
    n_cdims = var_declare->dim_list->num_val ;
1,704✔
48
    for ( ii=0 ; ii< n_cdims; ii++) {
3,376✔
49
        cdims[ii] = vval_int( &var_declare->dim_list->v_data[ii]);
1,672✔
50
    }
51

52
    /** @li Call declare_var to create a named-allocation. */
53
    if ((address = declare_var( type, class_name_string, n_stars, var_declare->name, n_cdims, cdims)) == NULL) {
3,408✔
54
        std::stringstream ss;
×
55
        ss << "Declaration \"" ;
×
56
        ss << make_decl_string( type, class_name_string, n_stars, var_declare->name, n_cdims, cdims);
×
57
        ss << "\" failed.";
×
58
        emitError( ss.str()) ;
×
59
        return ((void*)NULL);
×
60
    }
×
61

62
    /** @li Return the address of the allocation. */
63
    return(address);
1,704✔
64
}
1,704✔
65

66
/**
67
 @par Detailed Description:
68
 */
69
int Trick::MemoryManager::add_vars( TRICK_TYPE   type,
1,704✔
70
                                    const char*  class_name,
71
                                    VAR_LIST*    var_list,
72
                                    char*        units) {
73
    int i;
74
    int ret = 0;
1,704✔
75

76
    /** @par Design: */
77

78
    /** @li For each of the declarators in the VAR_LIST call add_var(). */
79
    for (i = 0; i < var_list->num_vars; i++) {
3,408✔
80
        if( add_var(type, class_name, &var_list->var_declare[i], units) == NULL) {
1,704✔
81
            ret = 1;
×
82
        }
83
    }
84
    /** @li Return the error status. */
85
    return (ret);
1,704✔
86
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc