Skip to content

Commit c155f65

Browse files
committed
intarray: return empty zero-dimensional array for an empty array
Previously a one-dimensional empty array was returned, but its text representation matched a zero-dimensional array, and there is no way to dump/reload a one-dimensional empty array. BACKWARD INCOMPATIBILITY Per report from elein
1 parent b810473 commit c155f65

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

contrib/intarray/_int_tool.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,13 @@ resize_intArrayType(ArrayType *a, int num)
246246
int nbytes = ARR_DATA_OFFSET(a) + sizeof(int) * num;
247247
int i;
248248

249+
/* if no elements, return a zero-dimensional array */
250+
if (num == 0)
251+
{
252+
ARR_NDIM(a) = 0;
253+
return a;
254+
}
255+
249256
if (num == ARRNELEMS(a))
250257
return a;
251258

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy