PostGIS  2.3.8dev-r@@SVN_REVISION@@

◆ trim()

static char* trim ( const char *  input)
static

Definition at line 262 of file raster2pgsql.c.

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

Referenced by main(), and rt_raster_get_perimeter().

262  {
263  char *rtn;
264  char *ptr;
265  uint32_t offset = 0;
266 
267  if (!input)
268  return NULL;
269  else if (!*input)
270  return (char *) input;
271 
272  /* trim left */
273  while (isspace(*input))
274  input++;
275 
276  /* trim right */
277  ptr = ((char *) input) + strlen(input);
278  while (isspace(*--ptr))
279  offset++;
280 
281  rtn = rtalloc(sizeof(char) * (strlen(input) - offset + 1));
282  if (NULL == rtn) {
283  rterror(_("trim: Not enough memory"));
284  return NULL;
285  }
286  strncpy(rtn, input, strlen(input) - offset);
287  rtn[strlen(input) - offset] = '\0';
288 
289  return rtn;
290 }
#define _(String)
Definition: shpcommon.h:24
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
Here is the call graph for this function:
Here is the caller graph for this function: