MCPcopy Create free account
hub / github.com/apache/cloudberry / make_null_val_with_blanks

Function make_null_val_with_blanks

contrib/formatter_fixedwidth/fixedwidth.c:242–264  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

240
241
242static char*
243make_null_val_with_blanks(char *value, int field_size)
244{
245 char *ret;
246 char *cur;
247 int actual_size = field_size + 1;
248 int size = strlen(value);
249
250 if ( size > field_size)
251 {
252 ereport(ERROR,
253 (errcode(ERRCODE_STRING_DATA_LENGTH_MISMATCH),
254 errmsg("the size of the null_value cannot be bigger than the field size")));
255 }
256
257 ret = (char*)palloc(actual_size);
258 strcpy(ret, value);
259 cur = ret + size;
260 memset(cur, ' ', actual_size - size);
261 ret[actual_size - 1] = '\0';
262
263 return ret;
264}
265
266/*
267 * make_val_with_blanks

Callers 1

Calls 3

errcodeFunction · 0.50
errmsgFunction · 0.50
pallocFunction · 0.50

Tested by

no test coverage detected