#define _MAX_PROTOCOL_LEN 25 #define _MAX_MODEL_LEN 25 SV* tdSensor() CODE: { char protocol[_MAX_PROTOCOL_LEN + 1]; char model[_MAX_MODEL_LEN + 1]; int id; int dataTypes; int rv = tdSensor( protocol, sizeof(protocol), model, sizeof(model), &id, &dataTypes ); if (rv == TELLSTICK_SUCCESS) { HV* hv = newHV(); SV* sv; /* In theory, hv_stores can fail. */ /* However, I suspect it can't happen for this new hash. */ /* It it were to happen here, this code would leak. */ sv = newSVpv(protocol, 0); hv_stores(hv, "protocol", sv); sv = newSVpv(model, 0); hv_stores(hv, "model", sv); sv = newIV(id); hv_stores(hv, "id", sv); sv = newIV(dataTypes); hv_stores(hv, "dataTypes", sv); RETVAL = newRV_noinc(MUTABLE_SV(hv)); } else { RETVAL = &PL_sv_undef; } } OUTPUT: RETVAL