mirror of
				https://gitlab.freedesktop.org/wlroots/wlroots.git
				synced 2025-11-03 09:01:40 -05:00 
			
		
		
		
	
		
			
	
	
		
			17 lines
		
	
	
	
		
			287 B
		
	
	
	
		
			C
		
	
	
	
	
	
		
		
			
		
	
	
			17 lines
		
	
	
	
		
			287 B
		
	
	
	
		
			C
		
	
	
	
	
	
| 
								 | 
							
								#include <stdbool.h>
							 | 
						||
| 
								 | 
							
								#include <stdlib.h>
							 | 
						||
| 
								 | 
							
								#include <string.h>
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#include "util/mem.h"
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								bool memdup(void *out, const void *src, size_t size) {
							 | 
						||
| 
								 | 
							
									void *dst = malloc(size);
							 | 
						||
| 
								 | 
							
									if (dst == NULL) {
							 | 
						||
| 
								 | 
							
										return false;
							 | 
						||
| 
								 | 
							
									}
							 | 
						||
| 
								 | 
							
									memcpy(dst, src, size);
							 | 
						||
| 
								 | 
							
									void **dst_ptr = out;
							 | 
						||
| 
								 | 
							
									*dst_ptr = dst;
							 | 
						||
| 
								 | 
							
									return true;
							 | 
						||
| 
								 | 
							
								}
							 |