Skip to content

Commit ffcf941

Browse files
committed
remove tmp array
1 parent b6d1bd5 commit ffcf941

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

drw.c

+10-9
Original file line numberDiff line numberDiff line change
@@ -242,20 +242,21 @@ drw_setscheme(Drw *drw, Clr *scm)
242242
}
243243

244244
Picture
245-
drw_create_resized_picture(Drw *drw, char *src, unsigned int srcw, unsigned int srch, unsigned int dstw, unsigned int dsth, char *tmp) {
245+
drw_picture_create_resized(Drw *drw, char *src, unsigned int srcw, unsigned int srch, unsigned int dstw, unsigned int dsth) {
246246
Pixmap pm;
247247
Picture pic;
248248
GC gc;
249249

250250
if (srcw <= (dstw << 1u) && srch <= (dsth << 1u)) {
251-
pm = XCreatePixmap(drw->dpy, drw->root, srcw, srch, 32);
252251
XImage img = {
253252
srcw, srch, 0, ZPixmap, src,
254253
ImageByteOrder(drw->dpy), BitmapUnit(drw->dpy), BitmapBitOrder(drw->dpy), 32,
255254
32, 0, 32,
256255
0, 0, 0
257256
};
258257
XInitImage(&img);
258+
259+
pm = XCreatePixmap(drw->dpy, drw->root, srcw, srch, 32);
259260
gc = XCreateGC(drw->dpy, pm, 0, NULL);
260261
XPutImage(drw->dpy, pm, gc, &img, 0, 0, 0, 0, srcw, srch);
261262
XFreeGC(drw->dpy, gc);
@@ -279,19 +280,19 @@ drw_create_resized_picture(Drw *drw, char *src, unsigned int srcw, unsigned int
279280
if (!scaled) return None;
280281
imlib_context_set_image(scaled);
281282
imlib_image_set_has_alpha(1);
282-
memcpy(tmp, imlib_image_get_data_for_reading_only(), (dstw * dsth) << 2);
283-
imlib_free_image_and_decache();
284283

285-
pm = XCreatePixmap(drw->dpy, drw->root, dstw, dsth, 32);
286284
XImage img = {
287-
dstw, dsth, 0, ZPixmap, tmp,
288-
ImageByteOrder(drw->dpy), BitmapUnit(drw->dpy), BitmapBitOrder(drw->dpy), 32,
289-
32, 0, 32,
290-
0, 0, 0
285+
dstw, dsth, 0, ZPixmap, (char *)imlib_image_get_data_for_reading_only(),
286+
ImageByteOrder(drw->dpy), BitmapUnit(drw->dpy), BitmapBitOrder(drw->dpy), 32,
287+
32, 0, 32,
288+
0, 0, 0
291289
};
292290
XInitImage(&img);
291+
292+
pm = XCreatePixmap(drw->dpy, drw->root, dstw, dsth, 32);
293293
gc = XCreateGC(drw->dpy, pm, 0, NULL);
294294
XPutImage(drw->dpy, pm, gc, &img, 0, 0, 0, 0, dstw, dsth);
295+
imlib_free_image_and_decache();
295296
XFreeGC(drw->dpy, gc);
296297

297298
pic = XRenderCreatePicture(drw->dpy, pm, XRenderFindStandardFormat(drw->dpy, PictStandardARGB32), 0, NULL);

drw.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ void drw_cur_free(Drw *drw, Cur *cursor);
5050
void drw_setfontset(Drw *drw, Fnt *set);
5151
void drw_setscheme(Drw *drw, Clr *scm);
5252

53-
Picture drw_create_resized_picture(Drw *drw, char *src, unsigned int src_w, unsigned int src_h, unsigned int dst_w, unsigned int dst_h, char *tmp);
53+
Picture drw_picture_create_resized(Drw *drw, char *src, unsigned int src_w, unsigned int src_h, unsigned int dst_w, unsigned int dst_h);
5454

5555
/* Drawing functions */
5656
void drw_rect(Drw *drw, int x, int y, unsigned int w, unsigned int h, int filled, int invert);

dwm.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -933,8 +933,7 @@ geticonprop(Window win, unsigned int *picw, unsigned int *pich)
933933
uint32_t i, *bstp32 = (uint32_t *)bstp;
934934
for (sz = w * h, i = 0; i < sz; ++i) bstp32[i] = prealpha(bstp[i]);
935935

936-
static char tmp[ICONSIZE * ICONSIZE << 2];
937-
Picture ret = drw_create_resized_picture(drw, (char *)bstp, w, h, icw, ich, tmp);
936+
Picture ret = drw_picture_create_resized(drw, (char *)bstp, w, h, icw, ich);
938937
XFree(p);
939938

940939
return ret;

0 commit comments

Comments
 (0)