diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2005-06-28 01:26:20 +0000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2005-06-28 01:26:20 +0000 |
commit | 364d6ce3ddda7aeabb4446b6f5b6fb7fb2b62df0 (patch) | |
tree | da79d1e98eaa3a8d8bd9bce587813957fc1864cb /libgps.c | |
parent | dde64ef97389884f0d79e48f39418d6bb51541b0 (diff) | |
download | gpsd-364d6ce3ddda7aeabb4446b6f5b6fb7fb2b62df0.tar.gz |
Eliminate dynamic-memory allocation from the daemon.
Only one calloc() is left, and that belongs to Gary in the Garmin
driver.
Diffstat (limited to 'libgps.c')
-rw-r--r-- | libgps.c | 14 |
1 files changed, 6 insertions, 8 deletions
@@ -103,13 +103,11 @@ int gps_close(struct gps_data_t *gpsdata) /* close a gpsd connection */ { int retval = close(gpsdata->gps_fd); - if (gpsdata->gps_id) + if (gpsdata->gps_id) { (void)free(gpsdata->gps_id); gpsdata->gps_id = NULL; - if (gpsdata->gps_device) { - (void)free(gpsdata->gps_device); - gpsdata->gps_device = NULL; } + gpsdata->gps_device[0] = '\0'; if (gpsdata->devicelist) { int i; for (i = 0; i < gpsdata->ndevices; i++) @@ -186,11 +184,11 @@ static void gps_unpack(char *buf, struct gps_data_t *gpsdata) case 'F': /*@ -mustfreeonly */ if (sp[2] == '?') - gpsdata->gps_device = NULL; + gpsdata->gps_device[0] = '\0'; else { - if (gpsdata->gps_device) - free(gpsdata->gps_id); - gpsdata->gps_device = strdup(sp+2); + /*@ -mayaliasunique @*/ + strncpy(gpsdata->gps_device, sp+2, PATH_MAX); + /*@ +mayaliasunique @*/ gpsdata->set |= DEVICE_SET; } /*@ +mustfreeonly */ |