Sha256: e2b2e8fcc0070fae353391a303384a6e0cb9e3976d795e292ef88493b5e78bbe

Contents?: true

Size: 1.66 KB

Versions: 25

Compression:

Stored size: 1.66 KB

Contents

/*
 Copyright 2017-2018 Craig Barnes.
 Copyright 2010 Google Inc.

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

    https://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "util.h"
#include "gumbo.h"

void* gumbo_alloc(size_t size) {
  void* ptr = malloc(size);
  if (unlikely(ptr == NULL)) {
    perror(__func__);
    abort();
  }
  return ptr;
}

void* gumbo_realloc(void* ptr, size_t size) {
  ptr = realloc(ptr, size);
  if (unlikely(ptr == NULL)) {
    perror(__func__);
    abort();
  }
  return ptr;
}

void gumbo_free(void* ptr) {
  free(ptr);
}

char* gumbo_strdup(const char* str) {
  const size_t size = strlen(str) + 1;
  // The strdup(3) function isn't available in strict "-std=c99" mode
  // (it's part of POSIX, not C99), so use malloc(3) and memcpy(3)
  // instead:
  char* buffer = gumbo_alloc(size);
  return memcpy(buffer, str, size);
}

#ifdef GUMBO_DEBUG
#include <stdarg.h>
// Debug function to trace operation of the parser
// (define GUMBO_DEBUG to use).
void gumbo_debug(const char* format, ...) {
  va_list args;
  va_start(args, format);
  vprintf(format, args);
  va_end(args);
  fflush(stdout);
}
#else
void gumbo_debug(const char* UNUSED_ARG(format), ...) {}
#endif

Version data entries

25 entries across 25 versions & 2 rubygems

Version Path
nokogiri-1.13.10 gumbo-parser/src/util.c
nokogiri-1.13.9 gumbo-parser/src/util.c
nokogiri-1.13.8 gumbo-parser/src/util.c
nokogiri-1.13.7 gumbo-parser/src/util.c
nokogiri-1.13.6 gumbo-parser/src/util.c
nokogiri-1.13.5 gumbo-parser/src/util.c
nokogiri-1.13.4 gumbo-parser/src/util.c
nokogiri-1.13.3 gumbo-parser/src/util.c
nokogiri-1.13.2 gumbo-parser/src/util.c
nokogiri-1.13.1 gumbo-parser/src/util.c
nokogiri-1.13.0 gumbo-parser/src/util.c
nokogiri-1.12.5 gumbo-parser/src/util.c
nokogiri-1.12.4 gumbo-parser/src/util.c
nokogiri-1.12.3 gumbo-parser/src/util.c
nokogiri-1.12.2 gumbo-parser/src/util.c
nokogiri-1.12.1 gumbo-parser/src/util.c
nokogiri-1.12.0 gumbo-parser/src/util.c
nokogiri-1.12.0.rc1 gumbo-parser/src/util.c
nokogumbo-2.0.5 gumbo-parser/src/util.c
nokogumbo-2.0.4 gumbo-parser/src/util.c