mirror of
				https://github.com/labwc/labwc.git
				synced 2025-11-03 09:01:51 -05:00 
			
		
		
		
	Add a BUF_INIT macro, which makes it easier to initialize a struct buf to an empty string (without a heap allocation). Add buf_move() to move the contents of one struct buf to another (the source is reset to BUF_INIT, analogous to C++ move-assignment). Use buf_reset() instead of directly calling `free(s->buf)` since the internal buf may not always be allocated by malloc() now.
		
			
				
	
	
		
			20 lines
		
	
	
	
		
			384 B
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			20 lines
		
	
	
	
		
			384 B
		
	
	
	
		
			C
		
	
	
	
	
	
/* SPDX-License-Identifier: GPL-2.0-only */
 | 
						|
/*
 | 
						|
 * Read file into memory
 | 
						|
 *
 | 
						|
 * Copyright Johan Malm 2020
 | 
						|
 */
 | 
						|
 | 
						|
#ifndef LABWC_GRAB_FILE_H
 | 
						|
#define LABWC_GRAB_FILE_H
 | 
						|
 | 
						|
#include "common/buf.h"
 | 
						|
 | 
						|
/**
 | 
						|
 * grab_file - read file into memory buffer
 | 
						|
 * @filename: file to read
 | 
						|
 * Free returned buffer with buf_reset().
 | 
						|
 */
 | 
						|
struct buf grab_file(const char *filename);
 | 
						|
 | 
						|
#endif /* LABWC_GRAB_FILE_H */
 |