538 shmget(IPC_PRIVATE, height * img->bytes_per_line, IPC_CREAT|0777); |
538 shmget(IPC_PRIVATE, height * img->bytes_per_line, IPC_CREAT|0777); |
539 if (shminfo->shmid < 0) { |
539 if (shminfo->shmid < 0) { |
540 J2dRlsTraceLn1(J2D_TRACE_ERROR, |
540 J2dRlsTraceLn1(J2D_TRACE_ERROR, |
541 "X11SD_SetupSharedSegment shmget has failed: %s", |
541 "X11SD_SetupSharedSegment shmget has failed: %s", |
542 strerror(errno)); |
542 strerror(errno)); |
|
543 free((void *)shminfo); |
|
544 XDestroyImage(img); |
543 return NULL; |
545 return NULL; |
544 } |
546 } |
545 |
547 |
546 shminfo->shmaddr = (char *) shmat(shminfo->shmid, 0, 0); |
548 shminfo->shmaddr = (char *) shmat(shminfo->shmid, 0, 0); |
547 if (shminfo->shmaddr == ((char *) -1)) { |
549 if (shminfo->shmaddr == ((char *) -1)) { |
548 shmctl(shminfo->shmid, IPC_RMID, 0); |
550 shmctl(shminfo->shmid, IPC_RMID, 0); |
549 J2dRlsTraceLn1(J2D_TRACE_ERROR, |
551 J2dRlsTraceLn1(J2D_TRACE_ERROR, |
550 "X11SD_SetupSharedSegment shmat has failed: %s", |
552 "X11SD_SetupSharedSegment shmat has failed: %s", |
551 strerror(errno)); |
553 strerror(errno)); |
|
554 free((void *)shminfo); |
|
555 XDestroyImage(img); |
552 return NULL; |
556 return NULL; |
553 } |
557 } |
554 |
558 |
555 shminfo->readOnly = False; |
559 shminfo->readOnly = False; |
556 |
560 |
567 |
571 |
568 if (isXShmAttachFailed() == JNI_TRUE) { |
572 if (isXShmAttachFailed() == JNI_TRUE) { |
569 J2dRlsTraceLn1(J2D_TRACE_ERROR, |
573 J2dRlsTraceLn1(J2D_TRACE_ERROR, |
570 "X11SD_SetupSharedSegment XShmAttach has failed: %s", |
574 "X11SD_SetupSharedSegment XShmAttach has failed: %s", |
571 strerror(errno)); |
575 strerror(errno)); |
|
576 shmdt(shminfo->shmaddr); |
|
577 free((void *)shminfo); |
|
578 XDestroyImage(img); |
572 return NULL; |
579 return NULL; |
573 } |
580 } |
574 |
581 |
575 img->data = shminfo->shmaddr; |
582 img->data = shminfo->shmaddr; |
576 img->obdata = (char *)shminfo; |
583 img->obdata = (char *)shminfo; |
1342 void X11SD_DisposeXImage(XImage * image) { |
1349 void X11SD_DisposeXImage(XImage * image) { |
1343 if (image != NULL) { |
1350 if (image != NULL) { |
1344 #ifdef MITSHM |
1351 #ifdef MITSHM |
1345 if (image->obdata != NULL) { |
1352 if (image->obdata != NULL) { |
1346 X11SD_DropSharedSegment((XShmSegmentInfo*)image->obdata); |
1353 X11SD_DropSharedSegment((XShmSegmentInfo*)image->obdata); |
1347 } else { |
1354 image->obdata = NULL; |
1348 free(image->data); |
1355 } |
1349 } |
|
1350 #else |
|
1351 free(image->data); |
|
1352 #endif /* MITSHM */ |
1356 #endif /* MITSHM */ |
1353 XFree(image); |
1357 XDestroyImage(image); |
1354 } |
1358 } |
1355 } |
1359 } |
1356 |
1360 |
1357 static JDgaStatus |
1361 static JDgaStatus |
1358 GetLockStub(JNIEnv *env, Display *display, void **dgaDev, |
1362 GetLockStub(JNIEnv *env, Display *display, void **dgaDev, |