PostGIS 3.0.6dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ chartrim()

static char * chartrim ( const char *  input,
char *  remove 
)
static

Definition at line 297 of file raster2pgsql.c.

297 {
298 char *rtn = NULL;
299 char *ptr = NULL;
300 uint32_t offset = 0;
301 size_t len = 0;
302
303 if (!input)
304 return NULL;
305 else if (!*input)
306 return (char *) input;
307
308 /* trim left */
309 while (strchr(remove, *input) != NULL)
310 input++;
311
312 /* trim right */
313 ptr = ((char *) input) + strlen(input);
314 while (strchr(remove, *--ptr) != NULL)
315 offset++;
316
317 len = strlen(input) - offset + 1;
318 rtn = rtalloc(sizeof(char) * len);
319 if (NULL == rtn) {
320 rterror(_("chartrim: Not enough memory"));
321 return NULL;
322 }
323 strncpy(rtn, input, len);
324 rtn[strlen(input) - offset] = '\0';
325
326 return rtn;
327}
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

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

Referenced by add_overview_constraints(), add_raster_constraints(), and create_index().

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