⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 local_services.h

📁 JPEG2000实现的源码
💻 H
字号:
/*****************************************************************************/
/* Copyright 1998, Hewlett-Packard Company                                   */
/* All rights reserved                                                       */
/* File: "local_services.h"                                                  */
/* Description: Abstracts platform and/or application dependent services,    */
/*              such as memory heap management, process termination and      */
/*              messaging.                                                   */
/* Author: David Taubman                                                     */
/* Affiliation: Hewlett-Packard and                                          */
/*              The University of New South Wales, Australia                 */
/* Version: VM6.0                                                            */
/* Last Revised: 27 December, 1999                                           */
/*****************************************************************************/
#ifndef LOCAL_SERVICES_H
#define LOCAL_SERVICES_H
#include <stdarg.h>

/* ========================================================================= */
/* --------------------------- Heap Management ----------------------------- */
/* ========================================================================= */

extern void
  local_memory_collect_stats(void);
    /* Causes the memory system to collect memory consumption statistics.
       This slows it down somewhat, but provides a helpful service for
       the assessment of new and current technology.  It also enables
       memory leak detection and tracing.  See `local_memory_set_stop_id'. */

extern void
  local_memory_set_stop_id(int stop_id);
    /* This function may be used only if `local_memory_collect_stats' has
       been called.  The next call to `local_malloc' which assigns the
       unique identifier, `stop_id', to a memory block, will cause the
       program to halt.  This should be used in conjunction with the
       memory reporting capability offered by `local_memory_report', which
       identifies leaks and supplies the identifiers of the memory blocks
       which were not deallocated. */

extern void *
  local_malloc(const char *key, int num_bytes);
    /* Same as `malloc', except that the `key' string identifies the
       type of object and the purpose to which the memory is being
       put, so as to ensure meaningful reporting of memory consumption.
       See examples throughout the source to understand how keys should
       be defined and used.  Note that the string supplied via `key' must
       be a static resource, not a dynamically allocated buffer or an
       array residing on the local stack.
           Note that unlike `malloc' the present function initializes the
       contents of the block of memory which is allocated to zero. */
extern void *
  local_realloc(void *ptr, int num_bytes);
    /* Same as `realloc' but works on memory allocated by
       `local_malloc'.  Note that newly allocated bytes will NOT
       be initialized by the call. */
extern void
  local_free(void *ptr);
    /* Same as `free' but works on memory allocated by `local_malloc'. */

extern void
  local_memory_report(void);
    /* Prints a comprehensive memory report from statistics accumulated
       by the `local_malloc', `local_realloc' and `local_free' functions.
       The function cannot succeed unless the `local_memory_collect_stats'
       function was called before any memory was allocatd. */

/* ========================================================================= */
/* ----------------------------- Termination ------------------------------- */
/* ========================================================================= */

extern void
  local_exit(int exit_code);
  /* Same as `exit'. */

/* ========================================================================= */
/* ------------------------------- Messages -------------------------------- */
/* ========================================================================= */

extern void
  local_printf(int indent, int width, char *format, ...);
  /* Similar to `printf', except that the output is formatted to consume a
     fixed number of whole lines, with `indent' spaces preceding each line
     and no more than `width' characters thereafter on any given line.  Thus,
     the function is responsible for inserting its own line breaks as often
     as necessary. */

extern void
  local_vprintf(int indent, int width, char *format, va_list v_args);
  /* Extendable interface for `local_printf'. */

extern void
  local_error(char *format, ...);
  /* Same as `local_printf', but pretty-prints the error message in a
     consistent manner and then exits through `local_exit' with code -1. */

#endif /* LOCAL_SERVICES_H */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -