A generic touchscreen calibration program for X.Org
Revisión | 40730129dee0b6e81747e4acc3fe158e228e58b4 (tree) |
---|---|
Tiempo | 2010-02-09 08:07:16 |
Autor | Tias Guns <tias@ulys...> |
Commiter | Tias Guns |
strdup is not ansi C, add my_strdup function
Thanks Johan Robben for pointing this out
@@ -85,6 +85,18 @@ class WrongCalibratorException : public std::invalid_argument { | ||
85 | 85 | std::invalid_argument(msg) {} |
86 | 86 | }; |
87 | 87 | |
88 | +// strdup: non-ansi | |
89 | +char* my_strdup(const char* s); | |
90 | +char* my_strdup(const char* s) { | |
91 | + size_t len = strlen(s) + 1; | |
92 | + void* p = malloc(len); | |
93 | + | |
94 | + if (p == NULL) | |
95 | + return NULL; | |
96 | + | |
97 | + return (char*) memcpy(p, s, len); | |
98 | +} | |
99 | + | |
88 | 100 | // all need struct XYinfo, and some the consts too |
89 | 101 | #include "calibrator.cpp" |
90 | 102 | #include "calibrator/calibratorXorgPrint.cpp" |
@@ -92,7 +104,6 @@ class WrongCalibratorException : public std::invalid_argument { | ||
92 | 104 | #include "calibrator/calibratorUsbtouchscreen.cpp" |
93 | 105 | |
94 | 106 | |
95 | - | |
96 | 107 | /** |
97 | 108 | * find a calibratable touchscreen device (using XInput) |
98 | 109 | * |
@@ -180,7 +191,7 @@ int find_device(const char* pre_device, bool verbose, bool list_devices, | ||
180 | 191 | // a calibratable touschscreen |
181 | 192 | found++; |
182 | 193 | device_id = list->id; |
183 | - device_name = strdup(list->name); | |
194 | + device_name = my_strdup(list->name); | |
184 | 195 | device_axys.x_min = ax[0].min_value; |
185 | 196 | device_axys.x_max = ax[0].max_value; |
186 | 197 | device_axys.y_min = ax[1].min_value; |