PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ trim()

static char* trim ( const char *  input)
static

Definition at line 262 of file raster2pgsql.c.

262  {
263  char *rtn;
264  char *ptr;
265  uint32_t offset = 0;
266  size_t len = 0;
267 
268  if (!input)
269  return NULL;
270  else if (!*input)
271  return (char *) input;
272 
273  /* trim left */
274  while (isspace(*input))
275  input++;
276 
277  /* trim right */
278  ptr = ((char *) input) + strlen(input);
279  while (isspace(*--ptr))
280  offset++;
281 
282  len = strlen(input) - offset + 1;
283  rtn = rtalloc(sizeof(char) * len);
284  if (NULL == rtn) {
285  rterror(_("trim: Not enough memory"));
286  return NULL;
287  }
288  strncpy(rtn, input, len);
289 
290  return rtn;
291 }
void rterror(const char *fmt,...)
Wrappers used for reporting errors and info.
Definition: rt_context.c:199
void * rtalloc(size_t size)
Wrappers used for managing memory.
Definition: rt_context.c:171
#define _(String)
Definition: shpcommon.h:24
unsigned int uint32_t
Definition: uthash.h:78

References _, rtalloc(), and rterror().

Referenced by _rti_raster_get_band_perimeter(), and rt_raster_get_perimeter().

Here is the call graph for this function:
Here is the caller graph for this function: