Photon 1.0.0
Loading...
Searching...
No Matches
util.h
Go to the documentation of this file.
1// Copyright 2010 Google Inc. All Rights Reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// Author: jdtang@google.com (Jonathan Tang)
16//
17// This contains some utility functions that didn't fit into any of the other
18// headers.
19
20#ifndef GUMBO_UTIL_H_
21#define GUMBO_UTIL_H_
22#ifdef _MSC_VER
23#define _CRT_SECURE_NO_WARNINGS
24#endif
25#include <stdbool.h>
26#include <stddef.h>
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
32// Forward declaration since it's passed into some of the functions in this
33// header.
35
36// Utility function for allocating & copying a null-terminated string into a
37// freshly-allocated buffer. This is necessary for proper memory management; we
38// have the convention that all const char* in parse tree structures are
39// freshly-allocated, so if we didn't copy, we'd try to delete a literal string
40// when the parse tree is destroyed.
41char* gumbo_copy_stringz(struct GumboInternalParser* parser, const char* str);
42
43// Allocate a chunk of memory, using the allocator specified in the Parser's
44// config options.
46 struct GumboInternalParser* parser, size_t num_bytes);
47
48// Deallocate a chunk of memory, using the deallocator specified in the Parser's
49// config options.
50void gumbo_parser_deallocate(struct GumboInternalParser* parser, void* ptr);
51
52// Debug wrapper for printf, to make it easier to turn off debugging info when
53// required.
54void gumbo_debug(const char* format, ...);
55
56#ifdef __cplusplus
57}
58#endif
59
60#endif // GUMBO_UTIL_H_
std::basic_string< Char > format(const text_style &ts, const S &format_str, const Args &... args)
Definition color.h:646
auto ptr(T p) -> const void *
Definition format.h:4568
Definition parser.h:35
char * gumbo_copy_stringz(struct GumboInternalParser *parser, const char *str)
Definition util.c:42
void gumbo_parser_deallocate(struct GumboInternalParser *parser, void *ptr)
Definition util.c:38
void * gumbo_parser_allocate(struct GumboInternalParser *parser, size_t num_bytes)
Definition util.c:34
void gumbo_debug(const char *format,...)
Definition util.c:50