@@ -76,8 +76,7 @@ shlib_entry_get(struct shlib_ctx *ctx, const char *name)
7676 return res ;
7777 res = calloc (1 , sizeof (* res ));
7878 if (!res ) {
79- xbps_error_printf ("out of memory\n" );
80- errno = ENOMEM ;
79+ xbps_error_oom ();
8180 return NULL ;
8281 }
8382 res -> name = name ;
@@ -109,16 +108,12 @@ collect_shlibs(struct shlib_ctx *ctx, xbps_array_t pkgs)
109108
110109 // can't set null values to xbps_dictionary so just use one boolean
111110 placeholder = xbps_bool_create (true);
112- if (!placeholder ) {
113- xbps_error_printf ("out of memory\n" );
114- return - ENOMEM ;
115- }
111+ if (!placeholder )
112+ return xbps_error_oom ();
116113
117114 ctx -> seen = xbps_dictionary_create ();
118- if (!ctx -> seen ) {
119- xbps_error_printf ("out of memory\n" );
120- return - ENOMEM ;
121- }
115+ if (!ctx -> seen )
116+ return xbps_error_oom ();
122117
123118 for (unsigned int i = 0 ; i < xbps_array_count (pkgs ); i ++ ) {
124119 const char * pkgname ;
@@ -131,10 +126,8 @@ collect_shlibs(struct shlib_ctx *ctx, xbps_array_t pkgs)
131126 xbps_error_printf ("invalid package: missing `pkgname` property\n" );
132127 return - EINVAL ;
133128 }
134- if (!xbps_dictionary_set (ctx -> seen , pkgname , placeholder )) {
135- xbps_error_printf ("out of memory\n" );
136- return - ENOMEM ;
137- }
129+ if (!xbps_dictionary_set (ctx -> seen , pkgname , placeholder ))
130+ return xbps_error_oom ();
138131
139132 if (xbps_transaction_pkg_type (pkgd ) == XBPS_TRANS_REMOVE )
140133 continue ;
@@ -148,10 +141,8 @@ collect_shlibs(struct shlib_ctx *ctx, xbps_array_t pkgs)
148141 }
149142
150143 iter = xbps_dictionary_iterator (ctx -> xhp -> pkgdb );
151- if (!iter ) {
152- xbps_error_printf ("out of memory\n" );
153- return - ENOMEM ;
154- }
144+ if (!iter )
145+ return xbps_error_oom ();
155146
156147 while ((obj = xbps_object_iterator_next (iter ))) {
157148 xbps_array_t array ;
@@ -210,18 +201,14 @@ check_shlibs(struct shlib_ctx *ctx, xbps_array_t pkgs)
210201 missing = xbps_xasprintf (
211202 "%s: broken, unresolvable shlib `%s'" ,
212203 pkgver , shlib );
213- if (!xbps_array_add_cstring_nocopy (ctx -> missing , missing )) {
214- xbps_error_printf ("out of memory\n" );
215- return - ENOMEM ;
216- }
204+ if (!xbps_array_add_cstring_nocopy (ctx -> missing , missing ))
205+ return xbps_error_oom ();
217206 }
218207 }
219208
220209 iter = xbps_dictionary_iterator (ctx -> xhp -> pkgdb );
221- if (!iter ) {
222- xbps_error_printf ("out of memory\n" );
223- return - ENOMEM ;
224- }
210+ if (!iter )
211+ return xbps_error_oom ();
225212
226213 while ((obj = xbps_object_iterator_next (iter ))) {
227214 xbps_array_t array ;
@@ -254,10 +241,8 @@ check_shlibs(struct shlib_ctx *ctx, xbps_array_t pkgs)
254241 missing = xbps_xasprintf (
255242 "%s: broken, unresolvable shlib `%s'" , pkgver ,
256243 shlib );
257- if (!xbps_array_add_cstring_nocopy (ctx -> missing , missing )) {
258- xbps_error_printf ("out of memory\n" );
259- return - ENOMEM ;
260- }
244+ if (!xbps_array_add_cstring_nocopy (ctx -> missing , missing ))
245+ return xbps_error_oom ();
261246 }
262247 }
263248
0 commit comments