Subversion Repositories public

Rev

Rev 136 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 136 Rev 246
Line 64... Line 64...
64
*/
64
*/
65
 
65
 
66
char *
66
char *
67
get_string ( garmin_packet * p, int * offset )
67
get_string ( garmin_packet * p, int * offset )
68
{
68
{
69
  char * start  = (char *)(p->packet.data + *offset);
69
  char * start;
70
  char * cursor = start;
70
  char * cursor;
71
  int    allow  = garmin_packet_size(p) - *offset;
71
  int    allow;
72
  char * ret    = NULL;
72
  char * ret    = NULL;
73
  int    bytes  = 0;
73
  int    bytes  = 0;
74
 
74
 
75
  /* early exit */
75
  /* early exit */
-
 
76
  if (!p || !offset) return NULL;
-
 
77
 
-
 
78
  start  = (char *)(p->packet.data + *offset);
-
 
79
  cursor = start;
-
 
80
  allow  = garmin_packet_size(p) - *offset;
76
 
81
 
77
  if ( allow <= 0 ) return NULL;
82
  if ( allow <= 0 ) return NULL;
78
 
83
 
79
  /* OK, we have space to work with. */
84
  /* OK, we have space to work with. */
80
 
85
 
Line 100... Line 105...
100
  char * start  = (char *)*buf;
105
  char * start  = (char *)*buf;
101
  char * cursor = start;
106
  char * cursor = start;
102
  char * ret    = NULL;
107
  char * ret    = NULL;
103
  int    bytes  = 0;
108
  int    bytes  = 0;
104
 
109
 
-
 
110
  if (!buf) return NULL;
-
 
111
 
105
  do { bytes++; } while ( *cursor++ );
112
  do { bytes++; } while ( *cursor++ );
106
 
113
 
107
  ret = malloc(bytes);
114
  ret = malloc(bytes);
108
  strncpy(ret,start,bytes-1);
115
  strncpy(ret,start,bytes-1);
109
 
116